<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html lang="en">

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <title>LCOV - code analysis - /usr/include/boost/thread/future.hpp</title>
  <link rel="stylesheet" type="text/css" href="../../../../gcov.css">
</head>

<body>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="title">LCOV - code coverage report</td></tr>
    <tr><td class="ruler"><img src="../../../../glass.png" width=3 height=3 alt=""></td></tr>

    <tr>
      <td width="100%">
        <table cellpadding=1 border=0 width="100%">
          <tr>
            <td width="10%" class="headerItem">Current view:</td>
            <td width="35%" class="headerValue"><a href="../../../../index.html">top level</a> - <a href="index.html">usr/include/boost/thread</a> - future.hpp<span style="font-size: 80%;"> (source / <a href="future.hpp.func-sort-c.html">functions</a>)</span></td>
            <td width="5%"></td>
            <td width="15%"></td>
            <td width="10%" class="headerCovTableHead">Hit</td>
            <td width="10%" class="headerCovTableHead">Total</td>
            <td width="15%" class="headerCovTableHead">Coverage</td>
          </tr>
          <tr>
            <td class="headerItem">Test:</td>
            <td class="headerValue">code analysis</td>
            <td></td>
            <td class="headerItem">Lines:</td>
            <td class="headerCovTableEntry">0</td>
            <td class="headerCovTableEntry">90</td>
            <td class="headerCovTableEntryLo">0.0 %</td>
          </tr>
          <tr>
            <td class="headerItem">Date:</td>
            <td class="headerValue">2020-09-11 22:50:33</td>
            <td></td>
            <td class="headerItem">Functions:</td>
            <td class="headerCovTableEntry">0</td>
            <td class="headerCovTableEntry">26</td>
            <td class="headerCovTableEntryLo">0.0 %</td>
          </tr>
          <tr>
            <td class="headerItem">Legend:</td>
            <td class="headerValueLeg">            Lines:
            <span class="coverLegendCov">hit</span>
            <span class="coverLegendNoCov">not hit</span>
</td>
            <td></td>
          </tr>
          <tr><td><img src="../../../../glass.png" width=3 height=3 alt=""></td></tr>
        </table>
      </td>
    </tr>

    <tr><td class="ruler"><img src="../../../../glass.png" width=3 height=3 alt=""></td></tr>
  </table>

  <table cellpadding=0 cellspacing=0 border=0>
    <tr>
      <td><br></td>
    </tr>
    <tr>
      <td>
<pre class="sourceHeading">          Line data    Source code</pre>
<pre class="source">
<a name="1"><span class="lineNum">       1 </span>            : //  (C) Copyright 2008-10 Anthony Williams</a>
<span class="lineNum">       2 </span>            : //  (C) Copyright 2011-2015 Vicente J. Botet Escriba
<span class="lineNum">       3 </span>            : //
<span class="lineNum">       4 </span>            : //  Distributed under the Boost Software License, Version 1.0. (See
<span class="lineNum">       5 </span>            : //  accompanying file LICENSE_1_0.txt or copy at
<span class="lineNum">       6 </span>            : //  http://www.boost.org/LICENSE_1_0.txt)
<span class="lineNum">       7 </span>            : 
<span class="lineNum">       8 </span>            : #ifndef BOOST_THREAD_FUTURE_HPP
<span class="lineNum">       9 </span>            : #define BOOST_THREAD_FUTURE_HPP
<span class="lineNum">      10 </span>            : 
<span class="lineNum">      11 </span>            : #include &lt;boost/thread/detail/config.hpp&gt;
<span class="lineNum">      12 </span>            : 
<span class="lineNum">      13 </span>            : // boost::thread::future requires exception handling
<span class="lineNum">      14 </span>            : // due to boost::exception::exception_ptr dependency
<span class="lineNum">      15 </span>            : 
<span class="lineNum">      16 </span>            : #ifndef BOOST_NO_EXCEPTIONS
<span class="lineNum">      17 </span>            : 
<span class="lineNum">      18 </span>            : #include &lt;boost/thread/condition_variable.hpp&gt;
<span class="lineNum">      19 </span>            : #include &lt;boost/thread/detail/move.hpp&gt;
<span class="lineNum">      20 </span>            : #include &lt;boost/thread/detail/invoker.hpp&gt;
<span class="lineNum">      21 </span>            : #include &lt;boost/thread/detail/invoke.hpp&gt;
<span class="lineNum">      22 </span>            : #include &lt;boost/thread/detail/is_convertible.hpp&gt;
<span class="lineNum">      23 </span>            : #include &lt;boost/thread/exceptional_ptr.hpp&gt;
<span class="lineNum">      24 </span>            : #include &lt;boost/thread/futures/future_error.hpp&gt;
<span class="lineNum">      25 </span>            : #include &lt;boost/thread/futures/future_error_code.hpp&gt;
<span class="lineNum">      26 </span>            : #include &lt;boost/thread/futures/future_status.hpp&gt;
<span class="lineNum">      27 </span>            : #include &lt;boost/thread/futures/is_future_type.hpp&gt;
<span class="lineNum">      28 </span>            : #include &lt;boost/thread/futures/launch.hpp&gt;
<span class="lineNum">      29 </span>            : #include &lt;boost/thread/futures/wait_for_all.hpp&gt;
<span class="lineNum">      30 </span>            : #include &lt;boost/thread/futures/wait_for_any.hpp&gt;
<span class="lineNum">      31 </span>            : #include &lt;boost/thread/lock_algorithms.hpp&gt;
<span class="lineNum">      32 </span>            : #include &lt;boost/thread/lock_types.hpp&gt;
<span class="lineNum">      33 </span>            : #include &lt;boost/thread/mutex.hpp&gt;
<span class="lineNum">      34 </span>            : #include &lt;boost/thread/thread_only.hpp&gt;
<span class="lineNum">      35 </span>            : #include &lt;boost/thread/thread_time.hpp&gt;
<span class="lineNum">      36 </span>            : 
<span class="lineNum">      37 </span>            : #if defined BOOST_THREAD_FUTURE_USES_OPTIONAL
<span class="lineNum">      38 </span>            : #include &lt;boost/optional.hpp&gt;
<span class="lineNum">      39 </span>            : #else
<span class="lineNum">      40 </span>            : #include &lt;boost/thread/csbl/memory/unique_ptr.hpp&gt;
<span class="lineNum">      41 </span>            : #endif
<span class="lineNum">      42 </span>            : 
<span class="lineNum">      43 </span>            : #include &lt;boost/assert.hpp&gt;
<span class="lineNum">      44 </span>            : #include &lt;boost/bind.hpp&gt;
<span class="lineNum">      45 </span>            : #ifdef BOOST_THREAD_USES_CHRONO
<span class="lineNum">      46 </span>            : #include &lt;boost/chrono/system_clocks.hpp&gt;
<span class="lineNum">      47 </span>            : #endif
<span class="lineNum">      48 </span>            : #include &lt;boost/core/enable_if.hpp&gt;
<span class="lineNum">      49 </span>            : #include &lt;boost/core/ref.hpp&gt;
<span class="lineNum">      50 </span>            : #include &lt;boost/enable_shared_from_this.hpp&gt;
<span class="lineNum">      51 </span>            : #include &lt;boost/exception_ptr.hpp&gt;
<span class="lineNum">      52 </span>            : #include &lt;boost/function.hpp&gt;
<span class="lineNum">      53 </span>            : #include &lt;boost/next_prior.hpp&gt;
<span class="lineNum">      54 </span>            : #include &lt;boost/scoped_array.hpp&gt;
<span class="lineNum">      55 </span>            : #include &lt;boost/shared_ptr.hpp&gt;
<span class="lineNum">      56 </span>            : #include &lt;boost/throw_exception.hpp&gt;
<span class="lineNum">      57 </span>            : #include &lt;boost/type_traits/conditional.hpp&gt;
<span class="lineNum">      58 </span>            : #include &lt;boost/type_traits/decay.hpp&gt;
<span class="lineNum">      59 </span>            : #include &lt;boost/type_traits/is_copy_constructible.hpp&gt;
<span class="lineNum">      60 </span>            : #include &lt;boost/type_traits/is_fundamental.hpp&gt;
<span class="lineNum">      61 </span>            : #include &lt;boost/type_traits/is_void.hpp&gt;
<span class="lineNum">      62 </span>            : #include &lt;boost/utility/result_of.hpp&gt;
<span class="lineNum">      63 </span>            : 
<span class="lineNum">      64 </span>            : 
<span class="lineNum">      65 </span>            : #if defined BOOST_THREAD_PROVIDES_FUTURE_CTOR_ALLOCATORS
<span class="lineNum">      66 </span>            : #include &lt;boost/thread/detail/memory.hpp&gt;
<span class="lineNum">      67 </span>            : #include &lt;boost/container/scoped_allocator.hpp&gt;
<span class="lineNum">      68 </span>            : #if ! defined  BOOST_NO_CXX11_ALLOCATOR
<span class="lineNum">      69 </span>            : #include &lt;memory&gt;
<span class="lineNum">      70 </span>            : #endif
<span class="lineNum">      71 </span>            : #endif
<span class="lineNum">      72 </span>            : 
<span class="lineNum">      73 </span>            : #if defined BOOST_THREAD_PROVIDES_FUTURE_WHEN_ALL_WHEN_ANY
<span class="lineNum">      74 </span>            : #include &lt;boost/thread/csbl/tuple.hpp&gt;
<span class="lineNum">      75 </span>            : #include &lt;boost/thread/csbl/vector.hpp&gt;
<span class="lineNum">      76 </span>            : #endif
<span class="lineNum">      77 </span>            : 
<span class="lineNum">      78 </span>            : #include &lt;algorithm&gt;
<span class="lineNum">      79 </span>            : #include &lt;list&gt;
<span class="lineNum">      80 </span>            : #include &lt;vector&gt;
<span class="lineNum">      81 </span>            : #include &lt;utility&gt;
<span class="lineNum">      82 </span>            : 
<span class="lineNum">      83 </span>            : #if defined BOOST_THREAD_PROVIDES_FUTURE
<span class="lineNum">      84 </span>            : #define BOOST_THREAD_FUTURE future
<span class="lineNum">      85 </span>            : #else
<span class="lineNum">      86 </span>            : #define BOOST_THREAD_FUTURE unique_future
<span class="lineNum">      87 </span>            : #endif
<span class="lineNum">      88 </span>            : 
<span class="lineNum">      89 </span>            : namespace boost
<span class="lineNum">      90 </span>            : {
<span class="lineNum">      91 </span>            :     namespace detail
<span class="lineNum">      92 </span>            :     {
<span class="lineNum">      93 </span>            :         struct relocker
<span class="lineNum">      94 </span>            :         {
<span class="lineNum">      95 </span>            :             boost::unique_lock&lt;boost::mutex&gt;&amp; lock_;
<span class="lineNum">      96 </span>            : 
<span class="lineNum">      97 </span>            :             relocker(boost::unique_lock&lt;boost::mutex&gt;&amp; lk):
<span class="lineNum">      98 </span>            :                 lock_(lk)
<span class="lineNum">      99 </span>            :             {
<span class="lineNum">     100 </span><span class="lineNoCov">          0 :                 lock_.unlock();</span>
<span class="lineNum">     101 </span>            :             }
<span class="lineNum">     102 </span>            :             ~relocker()
<span class="lineNum">     103 </span>            :             {
<span class="lineNum">     104 </span><span class="lineNoCov">          0 :               if (! lock_.owns_lock()) {</span>
<span class="lineNum">     105 </span><span class="lineNoCov">          0 :                 lock_.lock();</span>
<span class="lineNum">     106 </span>            :               }
<span class="lineNum">     107 </span>            :             }
<span class="lineNum">     108 </span>            :             void lock() {
<span class="lineNum">     109 </span>            :               if (! lock_.owns_lock()) {
<span class="lineNum">     110 </span>            :                 lock_.lock();
<span class="lineNum">     111 </span>            :               }
<span class="lineNum">     112 </span>            :             }
<span class="lineNum">     113 </span>            :         private:
<span class="lineNum">     114 </span>            :             relocker&amp; operator=(relocker const&amp;);
<span class="lineNum">     115 </span>            :         };
<span class="lineNum">     116 </span>            : 
<span class="lineNum">     117 </span>            :         struct shared_state_base : enable_shared_from_this&lt;shared_state_base&gt;
<span class="lineNum">     118 </span>            :         {
<span class="lineNum">     119 </span>            :             typedef std::list&lt;boost::condition_variable_any*&gt; waiter_list;
<span class="lineNum">     120 </span>            :             typedef waiter_list::iterator notify_when_ready_handle;
<span class="lineNum">     121 </span>            :             // This type should be only included conditionally if interruptions are allowed, but is included to maintain the same layout.
<span class="lineNum">     122 </span>            :             typedef shared_ptr&lt;shared_state_base&gt; continuation_ptr_type;
<span class="lineNum">     123 </span>            :             typedef std::vector&lt;continuation_ptr_type&gt; continuations_type;
<span class="lineNum">     124 </span>            : 
<span class="lineNum">     125 </span>            :             boost::exception_ptr exception;
<span class="lineNum">     126 </span>            :             bool done;
<span class="lineNum">     127 </span>            :             bool is_valid_;
<span class="lineNum">     128 </span>            :             bool is_deferred_;
<span class="lineNum">     129 </span>            :             bool is_constructed;
<span class="lineNum">     130 </span>            :             std::size_t cnt_;
<span class="lineNum">     131 </span>            :             launch policy_;
<span class="lineNum">     132 </span>            :             mutable boost::mutex mutex;
<span class="lineNum">     133 </span>            :             boost::condition_variable waiters;
<span class="lineNum">     134 </span>            :             waiter_list external_waiters;
<span class="lineNum">     135 </span>            :             boost::function&lt;void()&gt; callback;
<span class="lineNum">     136 </span>            :             // This declaration should be only included conditionally, but is included to maintain the same layout.
<span class="lineNum">     137 </span>            :             continuations_type continuations;
<a name="138"><span class="lineNum">     138 </span>            : </a>
<span class="lineNum">     139 </span>            :             // This declaration should be only included conditionally, but is included to maintain the same layout.
<span class="lineNum">     140 </span><span class="lineNoCov">          0 :             virtual void launch_continuation(boost::unique_lock&lt;boost::mutex&gt;&amp;, shared_ptr&lt;shared_state_base&gt;)</span>
<span class="lineNum">     141 </span>            :             {
<span class="lineNum">     142 </span><span class="lineNoCov">          0 :             }</span>
<span class="lineNum">     143 </span>            : 
<span class="lineNum">     144 </span>            :             shared_state_base():
<span class="lineNum">     145 </span>            :                 done(false),
<span class="lineNum">     146 </span>            :                 is_valid_(true),
<span class="lineNum">     147 </span>            :                 is_deferred_(false),
<span class="lineNum">     148 </span>            :                 is_constructed(false),
<span class="lineNum">     149 </span>            :                 cnt_(0),
<span class="lineNum">     150 </span>            :                 policy_(launch::none),
<a name="151"><span class="lineNum">     151 </span>            :                 continuations()</a>
<span class="lineNum">     152 </span>            :             {}
<span class="lineNum">     153 </span><span class="lineNoCov">          0 :             virtual ~shared_state_base()</span>
<span class="lineNum">     154 </span><span class="lineNoCov">          0 :             {</span>
<a name="155"><span class="lineNum">     155 </span>            :               BOOST_ASSERT(cnt_==0);</a>
<span class="lineNum">     156 </span><span class="lineNoCov">          0 :             }</span>
<span class="lineNum">     157 </span><span class="lineNoCov">          0 :             virtual void block_if_needed(boost::unique_lock&lt;boost::mutex&gt;&amp;)</span>
<span class="lineNum">     158 </span><span class="lineNoCov">          0 :             {}</span>
<span class="lineNum">     159 </span>            : 
<span class="lineNum">     160 </span>            :             bool valid(boost::unique_lock&lt;boost::mutex&gt;&amp;) { return is_valid_; }
<span class="lineNum">     161 </span>            :             bool valid() {
<span class="lineNum">     162 </span>            :               boost::unique_lock&lt;boost::mutex&gt; lk(this-&gt;mutex);
<span class="lineNum">     163 </span>            :               return valid(lk);
<span class="lineNum">     164 </span>            :             }
<span class="lineNum">     165 </span>            :             void invalidate(boost::unique_lock&lt;boost::mutex&gt;&amp;) { is_valid_ = false; }
<span class="lineNum">     166 </span>            :             void invalidate() {
<span class="lineNum">     167 </span>            :               boost::unique_lock&lt;boost::mutex&gt; lk(this-&gt;mutex);
<span class="lineNum">     168 </span>            :               invalidate(lk);
<span class="lineNum">     169 </span>            :             }
<span class="lineNum">     170 </span>            :             void validate(boost::unique_lock&lt;boost::mutex&gt;&amp;) { is_valid_ = true; }
<span class="lineNum">     171 </span>            :             void validate() {
<span class="lineNum">     172 </span>            :               boost::unique_lock&lt;boost::mutex&gt; lk(this-&gt;mutex);
<span class="lineNum">     173 </span>            :               validate(lk);
<span class="lineNum">     174 </span>            :             }
<span class="lineNum">     175 </span>            : 
<span class="lineNum">     176 </span>            :             void inc(boost::unique_lock&lt;boost::mutex&gt;&amp;) { ++cnt_; }
<span class="lineNum">     177 </span>            :             void inc() { boost::unique_lock&lt;boost::mutex&gt; lk(this-&gt;mutex); inc(lk); }
<span class="lineNum">     178 </span>            : 
<span class="lineNum">     179 </span>            :             void dec(boost::unique_lock&lt;boost::mutex&gt;&amp; lk) {
<span class="lineNum">     180 </span>            :               if (--cnt_ == 0) {
<span class="lineNum">     181 </span>            :                 block_if_needed(lk);
<span class="lineNum">     182 </span>            :               }
<span class="lineNum">     183 </span>            :             }
<span class="lineNum">     184 </span>            :             void dec() { boost::unique_lock&lt;boost::mutex&gt; lk(this-&gt;mutex); dec(lk); }
<span class="lineNum">     185 </span>            : 
<span class="lineNum">     186 </span>            :             void set_deferred()
<span class="lineNum">     187 </span>            :             {
<span class="lineNum">     188 </span>            :               is_deferred_ = true;
<span class="lineNum">     189 </span>            :               policy_ = launch::deferred;
<span class="lineNum">     190 </span>            :             }
<span class="lineNum">     191 </span>            :             void set_async()
<span class="lineNum">     192 </span>            :             {
<span class="lineNum">     193 </span>            :               is_deferred_ = false;
<span class="lineNum">     194 </span>            :               policy_ = launch::async;
<span class="lineNum">     195 </span>            :             }
<span class="lineNum">     196 </span>            : #ifdef BOOST_THREAD_PROVIDES_EXECUTORS
<span class="lineNum">     197 </span>            :             void set_executor()
<span class="lineNum">     198 </span>            :             {
<span class="lineNum">     199 </span>            :               is_deferred_ = false;
<span class="lineNum">     200 </span>            :               policy_ = launch::executor;
<span class="lineNum">     201 </span>            :             }
<span class="lineNum">     202 </span>            : #endif
<span class="lineNum">     203 </span>            :             notify_when_ready_handle notify_when_ready(boost::condition_variable_any&amp; cv)
<span class="lineNum">     204 </span>            :             {
<span class="lineNum">     205 </span>            :                 boost::unique_lock&lt;boost::mutex&gt; lock(this-&gt;mutex);
<span class="lineNum">     206 </span>            :                 do_callback(lock);
<span class="lineNum">     207 </span>            :                 return external_waiters.insert(external_waiters.end(),&amp;cv);
<span class="lineNum">     208 </span>            :             }
<span class="lineNum">     209 </span>            : 
<span class="lineNum">     210 </span>            :             void unnotify_when_ready(notify_when_ready_handle it)
<span class="lineNum">     211 </span>            :             {
<span class="lineNum">     212 </span>            :                 boost::lock_guard&lt;boost::mutex&gt; lock(this-&gt;mutex);
<span class="lineNum">     213 </span>            :                 external_waiters.erase(it);
<span class="lineNum">     214 </span>            :             }
<span class="lineNum">     215 </span>            : 
<span class="lineNum">     216 </span>            : #if defined BOOST_THREAD_PROVIDES_FUTURE_CONTINUATION
<span class="lineNum">     217 </span>            :             void do_continuation(boost::unique_lock&lt;boost::mutex&gt;&amp; lock)
<span class="lineNum">     218 </span>            :             {
<span class="lineNum">     219 </span>            :                 if (! continuations.empty()) {
<span class="lineNum">     220 </span>            :                   continuations_type the_continuations = continuations;
<span class="lineNum">     221 </span>            :                   continuations.clear();
<span class="lineNum">     222 </span>            :                   relocker rlk(lock);
<span class="lineNum">     223 </span>            :                   for (continuations_type::iterator it = the_continuations.begin(); it != the_continuations.end(); ++it) {
<span class="lineNum">     224 </span>            :                     boost::unique_lock&lt;boost::mutex&gt; cont_lock((*it)-&gt;mutex);
<span class="lineNum">     225 </span>            :                     (*it)-&gt;launch_continuation(cont_lock, *it);
<span class="lineNum">     226 </span>            :                   }
<span class="lineNum">     227 </span>            :                 }
<span class="lineNum">     228 </span>            :             }
<span class="lineNum">     229 </span>            : #else
<span class="lineNum">     230 </span>            :             void do_continuation(boost::unique_lock&lt;boost::mutex&gt;&amp;)
<span class="lineNum">     231 </span>            :             {
<span class="lineNum">     232 </span>            :             }
<span class="lineNum">     233 </span>            : #endif
<span class="lineNum">     234 </span>            : #if defined BOOST_THREAD_PROVIDES_FUTURE_CONTINUATION
<span class="lineNum">     235 </span>            :             virtual void set_continuation_ptr(continuation_ptr_type continuation, boost::unique_lock&lt;boost::mutex&gt;&amp; lock)
<span class="lineNum">     236 </span>            :             {
<span class="lineNum">     237 </span>            :               continuations.push_back(continuation);
<span class="lineNum">     238 </span>            :               if (done) {
<span class="lineNum">     239 </span>            :                 do_continuation(lock);
<span class="lineNum">     240 </span>            :               }
<a name="241"><span class="lineNum">     241 </span>            :             }</a>
<span class="lineNum">     242 </span>            : #endif
<span class="lineNum">     243 </span><span class="lineNoCov">          0 :             void mark_finished_internal(boost::unique_lock&lt;boost::mutex&gt;&amp; lock)</span>
<span class="lineNum">     244 </span>            :             {
<span class="lineNum">     245 </span><span class="lineNoCov">          0 :                 done=true;</span>
<span class="lineNum">     246 </span><span class="lineNoCov">          0 :                 waiters.notify_all();</span>
<span class="lineNum">     247 </span><span class="lineNoCov">          0 :                 for(waiter_list::const_iterator it=external_waiters.begin(),</span>
<span class="lineNum">     248 </span>            :                         end=external_waiters.end();it!=end;++it)
<span class="lineNum">     249 </span>            :                 {
<span class="lineNum">     250 </span><span class="lineNoCov">          0 :                     (*it)-&gt;notify_all();</span>
<span class="lineNum">     251 </span>            :                 }
<span class="lineNum">     252 </span>            :                 do_continuation(lock);
<span class="lineNum">     253 </span><span class="lineNoCov">          0 :             }</span>
<span class="lineNum">     254 </span>            :             void make_ready()
<span class="lineNum">     255 </span>            :             {
<span class="lineNum">     256 </span>            :               boost::unique_lock&lt;boost::mutex&gt; lock(this-&gt;mutex);
<span class="lineNum">     257 </span>            :               mark_finished_internal(lock);
<a name="258"><span class="lineNum">     258 </span>            :             }</a>
<span class="lineNum">     259 </span>            : 
<span class="lineNum">     260 </span><span class="lineNoCov">          0 :             void do_callback(boost::unique_lock&lt;boost::mutex&gt;&amp; lock)</span>
<span class="lineNum">     261 </span>            :             {
<span class="lineNum">     262 </span><span class="lineNoCov">          0 :                 if(callback &amp;&amp; !done)</span>
<span class="lineNum">     263 </span>            :                 {
<span class="lineNum">     264 </span>            :                     boost::function&lt;void()&gt; local_callback=callback;
<span class="lineNum">     265 </span>            :                     relocker relock(lock);
<span class="lineNum">     266 </span><span class="lineNoCov">          0 :                     local_callback();</span>
<span class="lineNum">     267 </span>            :                 }
<a name="268"><span class="lineNum">     268 </span><span class="lineNoCov">          0 :             }</span></a>
<span class="lineNum">     269 </span>            : 
<span class="lineNum">     270 </span><span class="lineNoCov">          0 :             virtual bool run_if_is_deferred()</span>
<span class="lineNum">     271 </span>            :             {
<span class="lineNum">     272 </span><span class="lineNoCov">          0 :               boost::unique_lock&lt;boost::mutex&gt; lk(this-&gt;mutex);</span>
<span class="lineNum">     273 </span><span class="lineNoCov">          0 :               if (is_deferred_)</span>
<span class="lineNum">     274 </span>            :               {
<span class="lineNum">     275 </span><span class="lineNoCov">          0 :                 is_deferred_=false;</span>
<span class="lineNum">     276 </span><span class="lineNoCov">          0 :                 execute(lk);</span>
<span class="lineNum">     277 </span>            :                 return true;
<span class="lineNum">     278 </span>            :               }
<span class="lineNum">     279 </span>            :               else
<a name="280"><span class="lineNum">     280 </span>            :                 return false;</a>
<span class="lineNum">     281 </span>            :             }
<span class="lineNum">     282 </span><span class="lineNoCov">          0 :             virtual bool run_if_is_deferred_or_ready()</span>
<span class="lineNum">     283 </span>            :             {
<span class="lineNum">     284 </span><span class="lineNoCov">          0 :               boost::unique_lock&lt;boost::mutex&gt; lk(this-&gt;mutex);</span>
<span class="lineNum">     285 </span><span class="lineNoCov">          0 :               if (is_deferred_)</span>
<span class="lineNum">     286 </span>            :               {
<span class="lineNum">     287 </span><span class="lineNoCov">          0 :                 is_deferred_=false;</span>
<span class="lineNum">     288 </span><span class="lineNoCov">          0 :                 execute(lk);</span>
<span class="lineNum">     289 </span>            : 
<span class="lineNum">     290 </span>            :                 return true;
<span class="lineNum">     291 </span>            :               }
<span class="lineNum">     292 </span>            :               else
<a name="293"><span class="lineNum">     293 </span><span class="lineNoCov">          0 :                 return done;</span></a>
<span class="lineNum">     294 </span>            :             }
<span class="lineNum">     295 </span><span class="lineNoCov">          0 :             void wait_internal(boost::unique_lock&lt;boost::mutex&gt; &amp;lk, bool rethrow=true)</span>
<span class="lineNum">     296 </span>            :             {
<span class="lineNum">     297 </span><span class="lineNoCov">          0 :               do_callback(lk);</span>
<span class="lineNum">     298 </span><span class="lineNoCov">          0 :               if (is_deferred_)</span>
<span class="lineNum">     299 </span>            :               {
<span class="lineNum">     300 </span><span class="lineNoCov">          0 :                 is_deferred_=false;</span>
<span class="lineNum">     301 </span><span class="lineNoCov">          0 :                 execute(lk);</span>
<span class="lineNum">     302 </span>            :               }
<span class="lineNum">     303 </span><span class="lineNoCov">          0 :               while(!done)</span>
<span class="lineNum">     304 </span>            :               {
<span class="lineNum">     305 </span><span class="lineNoCov">          0 :                   waiters.wait(lk);</span>
<span class="lineNum">     306 </span>            :               }
<span class="lineNum">     307 </span><span class="lineNoCov">          0 :               if(rethrow &amp;&amp; exception)</span>
<span class="lineNum">     308 </span>            :               {
<span class="lineNum">     309 </span><span class="lineNoCov">          0 :                   boost::rethrow_exception(exception);</span>
<span class="lineNum">     310 </span>            :               }
<a name="311"><span class="lineNum">     311 </span><span class="lineNoCov">          0 :             }</span></a>
<span class="lineNum">     312 </span>            : 
<span class="lineNum">     313 </span><span class="lineNoCov">          0 :             virtual void wait(boost::unique_lock&lt;boost::mutex&gt;&amp; lock, bool rethrow=true)</span>
<span class="lineNum">     314 </span>            :             {
<span class="lineNum">     315 </span><span class="lineNoCov">          0 :                 wait_internal(lock, rethrow);</span>
<span class="lineNum">     316 </span><span class="lineNoCov">          0 :             }</span>
<span class="lineNum">     317 </span>            : 
<span class="lineNum">     318 </span>            :             void wait(bool rethrow=true)
<span class="lineNum">     319 </span>            :             {
<span class="lineNum">     320 </span>            :                 boost::unique_lock&lt;boost::mutex&gt; lock(this-&gt;mutex);
<span class="lineNum">     321 </span>            :                 wait(lock, rethrow);
<span class="lineNum">     322 </span>            :             }
<span class="lineNum">     323 </span>            : 
<span class="lineNum">     324 </span>            : #if defined BOOST_THREAD_USES_DATETIME
<span class="lineNum">     325 </span>            :             bool timed_wait_until(boost::system_time const&amp; target_time)
<span class="lineNum">     326 </span>            :             {
<span class="lineNum">     327 </span>            :                 boost::unique_lock&lt;boost::mutex&gt; lock(this-&gt;mutex);
<span class="lineNum">     328 </span>            :                 if (is_deferred_)
<span class="lineNum">     329 </span>            :                     return false;
<span class="lineNum">     330 </span>            : 
<span class="lineNum">     331 </span>            :                 do_callback(lock);
<span class="lineNum">     332 </span>            :                 while(!done)
<span class="lineNum">     333 </span>            :                 {
<span class="lineNum">     334 </span>            :                     bool const success=waiters.timed_wait(lock,target_time);
<span class="lineNum">     335 </span>            :                     if(!success &amp;&amp; !done)
<span class="lineNum">     336 </span>            :                     {
<span class="lineNum">     337 </span>            :                         return false;
<span class="lineNum">     338 </span>            :                     }
<span class="lineNum">     339 </span>            :                 }
<span class="lineNum">     340 </span>            :                 return true;
<span class="lineNum">     341 </span>            :             }
<span class="lineNum">     342 </span>            : #endif
<span class="lineNum">     343 </span>            : #ifdef BOOST_THREAD_USES_CHRONO
<span class="lineNum">     344 </span>            : 
<span class="lineNum">     345 </span>            :             template &lt;class Clock, class Duration&gt;
<span class="lineNum">     346 </span>            :             future_status
<span class="lineNum">     347 </span>            :             wait_until(const chrono::time_point&lt;Clock, Duration&gt;&amp; abs_time)
<span class="lineNum">     348 </span>            :             {
<span class="lineNum">     349 </span>            :               boost::unique_lock&lt;boost::mutex&gt; lock(this-&gt;mutex);
<span class="lineNum">     350 </span>            :               if (is_deferred_)
<span class="lineNum">     351 </span>            :                   return future_status::deferred;
<span class="lineNum">     352 </span>            :               do_callback(lock);
<span class="lineNum">     353 </span>            :               while(!done)
<span class="lineNum">     354 </span>            :               {
<span class="lineNum">     355 </span>            :                   cv_status const st=waiters.wait_until(lock,abs_time);
<span class="lineNum">     356 </span>            :                   if(st==cv_status::timeout &amp;&amp; !done)
<span class="lineNum">     357 </span>            :                   {
<span class="lineNum">     358 </span>            :                     return future_status::timeout;
<span class="lineNum">     359 </span>            :                   }
<span class="lineNum">     360 </span>            :               }
<span class="lineNum">     361 </span>            :               return future_status::ready;
<span class="lineNum">     362 </span>            :             }
<span class="lineNum">     363 </span>            : #endif
<span class="lineNum">     364 </span>            :             void mark_exceptional_finish_internal(boost::exception_ptr const&amp; e, boost::unique_lock&lt;boost::mutex&gt;&amp; lock)
<span class="lineNum">     365 </span>            :             {
<span class="lineNum">     366 </span>            :                 exception=e;
<span class="lineNum">     367 </span><span class="lineNoCov">          0 :                 mark_finished_internal(lock);</span>
<a name="368"><span class="lineNum">     368 </span>            :             }</a>
<span class="lineNum">     369 </span>            : 
<span class="lineNum">     370 </span><span class="lineNoCov">          0 :             void mark_exceptional_finish()</span>
<span class="lineNum">     371 </span>            :             {
<span class="lineNum">     372 </span><span class="lineNoCov">          0 :                 boost::unique_lock&lt;boost::mutex&gt; lock(this-&gt;mutex);</span>
<span class="lineNum">     373 </span><span class="lineNoCov">          0 :                 mark_exceptional_finish_internal(boost::current_exception(), lock);</span>
<a name="374"><span class="lineNum">     374 </span><span class="lineNoCov">          0 :             }</span></a>
<span class="lineNum">     375 </span>            : 
<span class="lineNum">     376 </span><span class="lineNoCov">          0 :             void set_exception_at_thread_exit(exception_ptr e)</span>
<span class="lineNum">     377 </span>            :             {
<span class="lineNum">     378 </span><span class="lineNoCov">          0 :               unique_lock&lt;boost::mutex&gt; lk(this-&gt;mutex);</span>
<span class="lineNum">     379 </span><span class="lineNoCov">          0 :               if (has_value(lk))</span>
<span class="lineNum">     380 </span>            :               {
<span class="lineNum">     381 </span><span class="lineNoCov">          0 :                   throw_exception(promise_already_satisfied());</span>
<span class="lineNum">     382 </span>            :               }
<span class="lineNum">     383 </span>            :               exception=e;
<span class="lineNum">     384 </span><span class="lineNoCov">          0 :               this-&gt;is_constructed = true;</span>
<span class="lineNum">     385 </span><span class="lineNoCov">          0 :               detail::make_ready_at_thread_exit(shared_from_this());</span>
<span class="lineNum">     386 </span><span class="lineNoCov">          0 :             }</span>
<span class="lineNum">     387 </span>            : 
<span class="lineNum">     388 </span>            :             bool has_value() const
<span class="lineNum">     389 </span>            :             {
<span class="lineNum">     390 </span>            :                 boost::lock_guard&lt;boost::mutex&gt; lock(this-&gt;mutex);
<span class="lineNum">     391 </span>            :                 return done &amp;&amp; ! exception;
<span class="lineNum">     392 </span>            :             }
<span class="lineNum">     393 </span>            : 
<span class="lineNum">     394 </span>            :             bool has_value(unique_lock&lt;boost::mutex&gt;&amp; )  const
<span class="lineNum">     395 </span>            :             {
<span class="lineNum">     396 </span><span class="lineNoCov">          0 :                 return done &amp;&amp; ! exception;</span>
<span class="lineNum">     397 </span>            :             }
<span class="lineNum">     398 </span>            : 
<span class="lineNum">     399 </span>            :             bool has_exception()  const
<span class="lineNum">     400 </span>            :             {
<span class="lineNum">     401 </span>            :                 boost::lock_guard&lt;boost::mutex&gt; lock(this-&gt;mutex);
<span class="lineNum">     402 </span>            :                 return done &amp;&amp; exception;
<span class="lineNum">     403 </span>            :             }
<span class="lineNum">     404 </span>            : 
<span class="lineNum">     405 </span>            :             launch launch_policy(boost::unique_lock&lt;boost::mutex&gt;&amp;) const
<span class="lineNum">     406 </span>            :             {
<span class="lineNum">     407 </span>            :                 return policy_;
<span class="lineNum">     408 </span>            :             }
<span class="lineNum">     409 </span>            : 
<span class="lineNum">     410 </span>            :             future_state::state get_state(boost::unique_lock&lt;boost::mutex&gt;&amp; lk) const
<span class="lineNum">     411 </span>            :             {
<span class="lineNum">     412 </span>            :                 if(!done)
<span class="lineNum">     413 </span>            :                 {
<span class="lineNum">     414 </span>            :                     return future_state::waiting;
<span class="lineNum">     415 </span>            :                 }
<span class="lineNum">     416 </span>            :                 else
<span class="lineNum">     417 </span>            :                 {
<span class="lineNum">     418 </span>            :                     return future_state::ready;
<span class="lineNum">     419 </span>            :                 }
<span class="lineNum">     420 </span>            :             }
<span class="lineNum">     421 </span>            :             future_state::state get_state() const
<span class="lineNum">     422 </span>            :             {
<span class="lineNum">     423 </span>            :                 boost::lock_guard&lt;boost::mutex&gt; guard(this-&gt;mutex);
<span class="lineNum">     424 </span>            :                 if(!done)
<span class="lineNum">     425 </span>            :                 {
<span class="lineNum">     426 </span>            :                     return future_state::waiting;
<span class="lineNum">     427 </span>            :                 }
<span class="lineNum">     428 </span>            :                 else
<span class="lineNum">     429 </span>            :                 {
<span class="lineNum">     430 </span>            :                     return future_state::ready;
<span class="lineNum">     431 </span>            :                 }
<span class="lineNum">     432 </span>            :             }
<span class="lineNum">     433 </span>            : 
<span class="lineNum">     434 </span>            :             exception_ptr get_exception_ptr()
<span class="lineNum">     435 </span>            :             {
<span class="lineNum">     436 </span>            :                 boost::unique_lock&lt;boost::mutex&gt; lock(this-&gt;mutex);
<span class="lineNum">     437 </span>            :                 wait_internal(lock, false);
<span class="lineNum">     438 </span>            :                 return exception;
<span class="lineNum">     439 </span>            :             }
<span class="lineNum">     440 </span>            : 
<span class="lineNum">     441 </span>            :             template&lt;typename F,typename U&gt;
<span class="lineNum">     442 </span>            :             void set_wait_callback(F f,U* u)
<span class="lineNum">     443 </span>            :             {
<span class="lineNum">     444 </span>            :                 boost::lock_guard&lt;boost::mutex&gt; lock(this-&gt;mutex);
<span class="lineNum">     445 </span>            :                 callback=boost::bind(f,boost::ref(*u));
<a name="446"><span class="lineNum">     446 </span>            :             }</a>
<span class="lineNum">     447 </span>            : 
<span class="lineNum">     448 </span><span class="lineNoCov">          0 :             virtual void execute(boost::unique_lock&lt;boost::mutex&gt;&amp;) {}</span>
<span class="lineNum">     449 </span>            : 
<span class="lineNum">     450 </span>            :         private:
<span class="lineNum">     451 </span>            :             shared_state_base(shared_state_base const&amp;);
<span class="lineNum">     452 </span>            :             shared_state_base&amp; operator=(shared_state_base const&amp;);
<span class="lineNum">     453 </span>            :         };
<span class="lineNum">     454 </span>            : 
<span class="lineNum">     455 </span>            :         // Used to create stand-alone futures
<span class="lineNum">     456 </span>            :         template&lt;typename T&gt;
<span class="lineNum">     457 </span>            :         struct shared_state:
<span class="lineNum">     458 </span>            :             detail::shared_state_base
<span class="lineNum">     459 </span>            :         {
<span class="lineNum">     460 </span>            : #if defined BOOST_THREAD_FUTURE_USES_OPTIONAL
<span class="lineNum">     461 </span>            :               typedef boost::optional&lt;T&gt; storage_type;
<span class="lineNum">     462 </span>            : #else
<span class="lineNum">     463 </span>            :               typedef boost::csbl::unique_ptr&lt;T&gt; storage_type;
<span class="lineNum">     464 </span>            : #endif
<span class="lineNum">     465 </span>            : #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
<span class="lineNum">     466 </span>            :             typedef T const&amp; source_reference_type;
<span class="lineNum">     467 </span>            :             typedef BOOST_THREAD_RV_REF(T) rvalue_source_type;
<span class="lineNum">     468 </span>            :             typedef T move_dest_type;
<span class="lineNum">     469 </span>            : #elif defined BOOST_THREAD_USES_MOVE
<span class="lineNum">     470 </span>            :             typedef typename conditional&lt;boost::is_fundamental&lt;T&gt;::value,T,T const&amp;&gt;::type source_reference_type;
<span class="lineNum">     471 </span>            :             typedef BOOST_THREAD_RV_REF(T) rvalue_source_type;
<span class="lineNum">     472 </span>            :             typedef T move_dest_type;
<span class="lineNum">     473 </span>            : #else
<span class="lineNum">     474 </span>            :             typedef T&amp; source_reference_type;
<span class="lineNum">     475 </span>            :             typedef typename conditional&lt;boost::thread_detail::is_convertible&lt;T&amp;,BOOST_THREAD_RV_REF(T) &gt;::value, BOOST_THREAD_RV_REF(T),T const&amp;&gt;::type rvalue_source_type;
<span class="lineNum">     476 </span>            :             typedef typename conditional&lt;boost::thread_detail::is_convertible&lt;T&amp;,BOOST_THREAD_RV_REF(T) &gt;::value, BOOST_THREAD_RV_REF(T),T&gt;::type move_dest_type;
<span class="lineNum">     477 </span>            : #endif
<span class="lineNum">     478 </span>            : 
<span class="lineNum">     479 </span>            :             typedef const T&amp; shared_future_get_result_type;
<span class="lineNum">     480 </span>            : 
<span class="lineNum">     481 </span>            :             storage_type result;
<span class="lineNum">     482 </span>            : 
<span class="lineNum">     483 </span>            :             shared_state():
<span class="lineNum">     484 </span>            :                 result()
<span class="lineNum">     485 </span>            :             {}
<span class="lineNum">     486 </span>            : 
<span class="lineNum">     487 </span>            :             ~shared_state()
<span class="lineNum">     488 </span>            :             {}
<span class="lineNum">     489 </span>            : 
<span class="lineNum">     490 </span>            :             void mark_finished_with_result_internal(source_reference_type result_, boost::unique_lock&lt;boost::mutex&gt;&amp; lock)
<span class="lineNum">     491 </span>            :             {
<span class="lineNum">     492 </span>            : #if defined BOOST_THREAD_FUTURE_USES_OPTIONAL
<span class="lineNum">     493 </span>            :                 result = result_;
<span class="lineNum">     494 </span>            : #else
<span class="lineNum">     495 </span>            :                 result.reset(new T(result_));
<span class="lineNum">     496 </span>            : #endif
<span class="lineNum">     497 </span>            :                 this-&gt;mark_finished_internal(lock);
<span class="lineNum">     498 </span>            :             }
<span class="lineNum">     499 </span>            : 
<span class="lineNum">     500 </span>            :             void mark_finished_with_result_internal(rvalue_source_type result_, boost::unique_lock&lt;boost::mutex&gt;&amp; lock)
<span class="lineNum">     501 </span>            :             {
<span class="lineNum">     502 </span>            : #if defined BOOST_THREAD_FUTURE_USES_OPTIONAL
<span class="lineNum">     503 </span>            :                 result = boost::move(result_);
<span class="lineNum">     504 </span>            : #elif ! defined  BOOST_NO_CXX11_RVALUE_REFERENCES
<span class="lineNum">     505 </span>            :                 result.reset(new T(boost::move(result_)));
<span class="lineNum">     506 </span>            : #else
<span class="lineNum">     507 </span>            :                 result.reset(new T(static_cast&lt;rvalue_source_type&gt;(result_)));
<span class="lineNum">     508 </span>            : #endif
<span class="lineNum">     509 </span>            :                 this-&gt;mark_finished_internal(lock);
<span class="lineNum">     510 </span>            :             }
<span class="lineNum">     511 </span>            : 
<span class="lineNum">     512 </span>            : 
<span class="lineNum">     513 </span>            : #if ! defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
<span class="lineNum">     514 </span>            :             template &lt;class ...Args&gt;
<span class="lineNum">     515 </span>            :             void mark_finished_with_result_internal(boost::unique_lock&lt;boost::mutex&gt;&amp; lock, BOOST_THREAD_FWD_REF(Args)... args)
<span class="lineNum">     516 </span>            :             {
<span class="lineNum">     517 </span>            : #if defined BOOST_THREAD_FUTURE_USES_OPTIONAL
<span class="lineNum">     518 </span>            :                 result.emplace(boost::forward&lt;Args&gt;(args)...);
<span class="lineNum">     519 </span>            : #else
<span class="lineNum">     520 </span>            :                 result.reset(new T(boost::forward&lt;Args&gt;(args)...));
<span class="lineNum">     521 </span>            : #endif
<span class="lineNum">     522 </span>            :                 this-&gt;mark_finished_internal(lock);
<span class="lineNum">     523 </span>            :             }
<span class="lineNum">     524 </span>            : #endif
<span class="lineNum">     525 </span>            : 
<span class="lineNum">     526 </span>            :             void mark_finished_with_result(source_reference_type result_)
<span class="lineNum">     527 </span>            :             {
<span class="lineNum">     528 </span>            :                 boost::unique_lock&lt;boost::mutex&gt; lock(this-&gt;mutex);
<span class="lineNum">     529 </span>            :                 this-&gt;mark_finished_with_result_internal(result_, lock);
<span class="lineNum">     530 </span>            :             }
<span class="lineNum">     531 </span>            : 
<span class="lineNum">     532 </span>            :             void mark_finished_with_result(rvalue_source_type result_)
<span class="lineNum">     533 </span>            :             {
<span class="lineNum">     534 </span>            :                 boost::unique_lock&lt;boost::mutex&gt; lock(this-&gt;mutex);
<span class="lineNum">     535 </span>            : 
<span class="lineNum">     536 </span>            : #if ! defined  BOOST_NO_CXX11_RVALUE_REFERENCES
<span class="lineNum">     537 </span>            :                 mark_finished_with_result_internal(boost::move(result_), lock);
<span class="lineNum">     538 </span>            : #else
<span class="lineNum">     539 </span>            :                 mark_finished_with_result_internal(static_cast&lt;rvalue_source_type&gt;(result_), lock);
<span class="lineNum">     540 </span>            : #endif
<span class="lineNum">     541 </span>            :             }
<span class="lineNum">     542 </span>            : 
<span class="lineNum">     543 </span>            :             storage_type&amp; get_storage(boost::unique_lock&lt;boost::mutex&gt;&amp; lk)
<span class="lineNum">     544 </span>            :             {
<span class="lineNum">     545 </span>            :                 wait_internal(lk);
<span class="lineNum">     546 </span>            :                 return result;
<span class="lineNum">     547 </span>            :             }
<span class="lineNum">     548 </span>            :             virtual move_dest_type get(boost::unique_lock&lt;boost::mutex&gt;&amp; lk)
<span class="lineNum">     549 </span>            :             {
<span class="lineNum">     550 </span>            :                 return boost::move(*get_storage(lk));
<span class="lineNum">     551 </span>            :             }
<span class="lineNum">     552 </span>            :             move_dest_type get()
<span class="lineNum">     553 </span>            :             {
<span class="lineNum">     554 </span>            :                 boost::unique_lock&lt;boost::mutex&gt; lk(this-&gt;mutex);
<span class="lineNum">     555 </span>            :                 return this-&gt;get(lk);
<span class="lineNum">     556 </span>            :             }
<span class="lineNum">     557 </span>            : 
<span class="lineNum">     558 </span>            :             virtual shared_future_get_result_type get_sh(boost::unique_lock&lt;boost::mutex&gt;&amp; lk)
<span class="lineNum">     559 </span>            :             {
<span class="lineNum">     560 </span>            :                 return *get_storage(lk);
<span class="lineNum">     561 </span>            :             }
<span class="lineNum">     562 </span>            :             shared_future_get_result_type get_sh()
<span class="lineNum">     563 </span>            :             {
<span class="lineNum">     564 </span>            :                 boost::unique_lock&lt;boost::mutex&gt; lk(this-&gt;mutex);
<span class="lineNum">     565 </span>            :                 return this-&gt;get_sh(lk);
<span class="lineNum">     566 </span>            :             }
<span class="lineNum">     567 </span>            : 
<span class="lineNum">     568 </span>            :             void set_value_at_thread_exit(source_reference_type result_)
<span class="lineNum">     569 </span>            :             {
<span class="lineNum">     570 </span>            :               unique_lock&lt;boost::mutex&gt; lk(this-&gt;mutex);
<span class="lineNum">     571 </span>            :               if (this-&gt;has_value(lk))
<span class="lineNum">     572 </span>            :               {
<span class="lineNum">     573 </span>            :                   throw_exception(promise_already_satisfied());
<span class="lineNum">     574 </span>            :               }
<span class="lineNum">     575 </span>            : #if defined BOOST_THREAD_FUTURE_USES_OPTIONAL
<span class="lineNum">     576 </span>            :               result = result_;
<span class="lineNum">     577 </span>            : #else
<span class="lineNum">     578 </span>            :               result.reset(new T(result_));
<span class="lineNum">     579 </span>            : #endif
<span class="lineNum">     580 </span>            : 
<span class="lineNum">     581 </span>            :               this-&gt;is_constructed = true;
<span class="lineNum">     582 </span>            :               detail::make_ready_at_thread_exit(shared_from_this());
<span class="lineNum">     583 </span>            :             }
<span class="lineNum">     584 </span>            :             void set_value_at_thread_exit(rvalue_source_type result_)
<span class="lineNum">     585 </span>            :             {
<span class="lineNum">     586 </span>            :               unique_lock&lt;boost::mutex&gt; lk(this-&gt;mutex);
<span class="lineNum">     587 </span>            :               if (this-&gt;has_value(lk))
<span class="lineNum">     588 </span>            :                   throw_exception(promise_already_satisfied());
<span class="lineNum">     589 </span>            : 
<span class="lineNum">     590 </span>            : #if ! defined  BOOST_NO_CXX11_RVALUE_REFERENCES
<span class="lineNum">     591 </span>            : #if defined BOOST_THREAD_FUTURE_USES_OPTIONAL
<span class="lineNum">     592 </span>            :                 result = boost::move(result_);
<span class="lineNum">     593 </span>            : #else
<span class="lineNum">     594 </span>            :                 result.reset(new T(boost::move(result_)));
<span class="lineNum">     595 </span>            : #endif
<span class="lineNum">     596 </span>            : #else
<span class="lineNum">     597 </span>            : #if defined BOOST_THREAD_FUTURE_USES_OPTIONAL
<span class="lineNum">     598 </span>            :                 result = boost::move(result_);
<span class="lineNum">     599 </span>            : #else
<span class="lineNum">     600 </span>            :                 result.reset(new T(static_cast&lt;rvalue_source_type&gt;(result_)));
<span class="lineNum">     601 </span>            : #endif
<span class="lineNum">     602 </span>            : #endif
<span class="lineNum">     603 </span>            :               this-&gt;is_constructed = true;
<span class="lineNum">     604 </span>            :               detail::make_ready_at_thread_exit(shared_from_this());
<span class="lineNum">     605 </span>            :             }
<span class="lineNum">     606 </span>            : 
<span class="lineNum">     607 </span>            :         private:
<span class="lineNum">     608 </span>            :             shared_state(shared_state const&amp;);
<span class="lineNum">     609 </span>            :             shared_state&amp; operator=(shared_state const&amp;);
<span class="lineNum">     610 </span>            :         };
<span class="lineNum">     611 </span>            : 
<span class="lineNum">     612 </span>            :         template&lt;typename T&gt;
<span class="lineNum">     613 </span>            :         struct shared_state&lt;T&amp;&gt;:
<span class="lineNum">     614 </span>            :             detail::shared_state_base
<span class="lineNum">     615 </span>            :         {
<span class="lineNum">     616 </span>            :             typedef T* storage_type;
<span class="lineNum">     617 </span>            :             typedef T&amp; source_reference_type;
<span class="lineNum">     618 </span>            :             typedef T&amp; move_dest_type;
<span class="lineNum">     619 </span>            :             typedef T&amp; shared_future_get_result_type;
<span class="lineNum">     620 </span>            : 
<span class="lineNum">     621 </span>            :             T* result;
<span class="lineNum">     622 </span>            : 
<span class="lineNum">     623 </span>            :             shared_state():
<span class="lineNum">     624 </span>            :                 result(0)
<span class="lineNum">     625 </span>            :             {}
<span class="lineNum">     626 </span>            : 
<span class="lineNum">     627 </span>            :             ~shared_state()
<span class="lineNum">     628 </span>            :             {
<span class="lineNum">     629 </span>            :             }
<span class="lineNum">     630 </span>            : 
<span class="lineNum">     631 </span>            :             void mark_finished_with_result_internal(source_reference_type result_, boost::unique_lock&lt;boost::mutex&gt;&amp; lock)
<span class="lineNum">     632 </span>            :             {
<span class="lineNum">     633 </span>            :                 result= &amp;result_;
<span class="lineNum">     634 </span>            :                 mark_finished_internal(lock);
<span class="lineNum">     635 </span>            :             }
<span class="lineNum">     636 </span>            : 
<span class="lineNum">     637 </span>            :             void mark_finished_with_result(source_reference_type result_)
<span class="lineNum">     638 </span>            :             {
<span class="lineNum">     639 </span>            :                 boost::unique_lock&lt;boost::mutex&gt; lock(this-&gt;mutex);
<span class="lineNum">     640 </span>            :                 mark_finished_with_result_internal(result_, lock);
<span class="lineNum">     641 </span>            :             }
<span class="lineNum">     642 </span>            : 
<span class="lineNum">     643 </span>            :             virtual T&amp; get(boost::unique_lock&lt;boost::mutex&gt;&amp; lock)
<span class="lineNum">     644 </span>            :             {
<span class="lineNum">     645 </span>            :                 wait_internal(lock);
<span class="lineNum">     646 </span>            :                 return *result;
<span class="lineNum">     647 </span>            :             }
<span class="lineNum">     648 </span>            :             T&amp; get()
<span class="lineNum">     649 </span>            :             {
<span class="lineNum">     650 </span>            :                 boost::unique_lock&lt;boost::mutex&gt; lk(this-&gt;mutex);
<span class="lineNum">     651 </span>            :                 return get(lk);
<span class="lineNum">     652 </span>            :             }
<span class="lineNum">     653 </span>            : 
<span class="lineNum">     654 </span>            :             virtual T&amp; get_sh(boost::unique_lock&lt;boost::mutex&gt;&amp; lock)
<span class="lineNum">     655 </span>            :             {
<span class="lineNum">     656 </span>            :                 wait_internal(lock);
<span class="lineNum">     657 </span>            :                 return *result;
<span class="lineNum">     658 </span>            :             }
<span class="lineNum">     659 </span>            :             T&amp; get_sh()
<span class="lineNum">     660 </span>            :             {
<span class="lineNum">     661 </span>            :                 boost::unique_lock&lt;boost::mutex&gt; lock(this-&gt;mutex);
<span class="lineNum">     662 </span>            :                 return get_sh(lock);
<span class="lineNum">     663 </span>            :             }
<span class="lineNum">     664 </span>            : 
<span class="lineNum">     665 </span>            :             void set_value_at_thread_exit(T&amp; result_)
<span class="lineNum">     666 </span>            :             {
<span class="lineNum">     667 </span>            :               unique_lock&lt;boost::mutex&gt; lk(this-&gt;mutex);
<span class="lineNum">     668 </span>            :               if (this-&gt;has_value(lk))
<span class="lineNum">     669 </span>            :                   throw_exception(promise_already_satisfied());
<span class="lineNum">     670 </span>            :               result= &amp;result_;
<span class="lineNum">     671 </span>            :               this-&gt;is_constructed = true;
<span class="lineNum">     672 </span>            :               detail::make_ready_at_thread_exit(shared_from_this());
<span class="lineNum">     673 </span>            :             }
<span class="lineNum">     674 </span>            : 
<span class="lineNum">     675 </span>            :         private:
<span class="lineNum">     676 </span>            :             shared_state(shared_state const&amp;);
<span class="lineNum">     677 </span>            :             shared_state&amp; operator=(shared_state const&amp;);
<span class="lineNum">     678 </span>            :         };
<a name="679"><span class="lineNum">     679 </span>            : </a>
<span class="lineNum">     680 </span>            :         template&lt;&gt;
<span class="lineNum">     681 </span><span class="lineNoCov">          0 :         struct shared_state&lt;void&gt;:</span>
<span class="lineNum">     682 </span>            :             detail::shared_state_base
<span class="lineNum">     683 </span>            :         {
<span class="lineNum">     684 </span>            :             typedef void shared_future_get_result_type;
<span class="lineNum">     685 </span>            :             typedef void move_dest_type;
<span class="lineNum">     686 </span>            : 
<span class="lineNum">     687 </span>            :             shared_state()
<span class="lineNum">     688 </span>            :             {}
<span class="lineNum">     689 </span>            : 
<span class="lineNum">     690 </span>            :             void mark_finished_with_result_internal(boost::unique_lock&lt;boost::mutex&gt;&amp; lock)
<span class="lineNum">     691 </span>            :             {
<span class="lineNum">     692 </span><span class="lineNoCov">          0 :                 mark_finished_internal(lock);</span>
<a name="693"><span class="lineNum">     693 </span>            :             }</a>
<span class="lineNum">     694 </span>            : 
<span class="lineNum">     695 </span><span class="lineNoCov">          0 :             void mark_finished_with_result()</span>
<span class="lineNum">     696 </span>            :             {
<span class="lineNum">     697 </span><span class="lineNoCov">          0 :                 boost::unique_lock&lt;boost::mutex&gt; lock(this-&gt;mutex);</span>
<span class="lineNum">     698 </span>            :                 mark_finished_with_result_internal(lock);
<a name="699"><span class="lineNum">     699 </span><span class="lineNoCov">          0 :             }</span></a>
<span class="lineNum">     700 </span>            : 
<span class="lineNum">     701 </span><span class="lineNoCov">          0 :             virtual void get(boost::unique_lock&lt;boost::mutex&gt;&amp; lock)</span>
<span class="lineNum">     702 </span>            :             {
<span class="lineNum">     703 </span><span class="lineNoCov">          0 :                 this-&gt;wait_internal(lock);</span>
<span class="lineNum">     704 </span><span class="lineNoCov">          0 :             }</span>
<span class="lineNum">     705 </span>            :             void get()
<span class="lineNum">     706 </span>            :             {
<span class="lineNum">     707 </span>            :                 boost::unique_lock&lt;boost::mutex&gt; lock(this-&gt;mutex);
<span class="lineNum">     708 </span>            :                 this-&gt;get(lock);
<a name="709"><span class="lineNum">     709 </span>            :             }</a>
<span class="lineNum">     710 </span>            : 
<span class="lineNum">     711 </span><span class="lineNoCov">          0 :             virtual void get_sh(boost::unique_lock&lt;boost::mutex&gt;&amp; lock)</span>
<span class="lineNum">     712 </span>            :             {
<span class="lineNum">     713 </span><span class="lineNoCov">          0 :                 this-&gt;wait_internal(lock);</span>
<span class="lineNum">     714 </span><span class="lineNoCov">          0 :             }</span>
<span class="lineNum">     715 </span>            :             void get_sh()
<span class="lineNum">     716 </span>            :             {
<span class="lineNum">     717 </span>            :                 boost::unique_lock&lt;boost::mutex&gt; lock(this-&gt;mutex);
<span class="lineNum">     718 </span>            :                 this-&gt;get_sh(lock);
<a name="719"><span class="lineNum">     719 </span>            :             }</a>
<span class="lineNum">     720 </span>            : 
<span class="lineNum">     721 </span><span class="lineNoCov">          0 :             void set_value_at_thread_exit()</span>
<span class="lineNum">     722 </span>            :             {
<span class="lineNum">     723 </span><span class="lineNoCov">          0 :               unique_lock&lt;boost::mutex&gt; lk(this-&gt;mutex);</span>
<span class="lineNum">     724 </span><span class="lineNoCov">          0 :               if (this-&gt;has_value(lk))</span>
<span class="lineNum">     725 </span>            :               {
<span class="lineNum">     726 </span><span class="lineNoCov">          0 :                   throw_exception(promise_already_satisfied());</span>
<span class="lineNum">     727 </span>            :               }
<span class="lineNum">     728 </span><span class="lineNoCov">          0 :               this-&gt;is_constructed = true;</span>
<span class="lineNum">     729 </span><span class="lineNoCov">          0 :               detail::make_ready_at_thread_exit(shared_from_this());</span>
<span class="lineNum">     730 </span><span class="lineNoCov">          0 :             }</span>
<span class="lineNum">     731 </span>            :         private:
<span class="lineNum">     732 </span>            :             shared_state(shared_state const&amp;);
<span class="lineNum">     733 </span>            :             shared_state&amp; operator=(shared_state const&amp;);
<span class="lineNum">     734 </span>            :         };
<span class="lineNum">     735 </span>            : 
<span class="lineNum">     736 </span>            :         /////////////////////////
<span class="lineNum">     737 </span>            :         /// future_async_shared_state_base
<span class="lineNum">     738 </span>            :         /////////////////////////
<span class="lineNum">     739 </span>            :         template&lt;typename Rp&gt;
<span class="lineNum">     740 </span>            :         struct future_async_shared_state_base: shared_state&lt;Rp&gt;
<span class="lineNum">     741 </span>            :         {
<span class="lineNum">     742 </span>            :           typedef shared_state&lt;Rp&gt; base_type;
<span class="lineNum">     743 </span>            :         protected:
<span class="lineNum">     744 </span>            :           boost::thread thr_;
<span class="lineNum">     745 </span>            :           void join()
<span class="lineNum">     746 </span>            :           {
<span class="lineNum">     747 </span>            :               if (thr_.joinable()) thr_.join();
<span class="lineNum">     748 </span>            :           }
<span class="lineNum">     749 </span>            :         public:
<span class="lineNum">     750 </span>            :           future_async_shared_state_base()
<span class="lineNum">     751 </span>            :           {
<span class="lineNum">     752 </span>            :             this-&gt;set_async();
<span class="lineNum">     753 </span>            :           }
<span class="lineNum">     754 </span>            : 
<span class="lineNum">     755 </span>            :           virtual void block_if_needed(boost::unique_lock&lt;boost::mutex&gt;&amp; lk)
<span class="lineNum">     756 </span>            :           {
<span class="lineNum">     757 </span>            :             this-&gt;wait(lk, false);
<span class="lineNum">     758 </span>            :           }
<span class="lineNum">     759 </span>            : 
<span class="lineNum">     760 </span>            :           ~future_async_shared_state_base()
<span class="lineNum">     761 </span>            :           {
<span class="lineNum">     762 </span>            :             join();
<span class="lineNum">     763 </span>            :           }
<span class="lineNum">     764 </span>            : 
<span class="lineNum">     765 </span>            :           virtual void wait(boost::unique_lock&lt;boost::mutex&gt;&amp; lk, bool rethrow)
<span class="lineNum">     766 </span>            :           {
<span class="lineNum">     767 </span>            :               {
<span class="lineNum">     768 </span>            :                 relocker rlk(lk);
<span class="lineNum">     769 </span>            :                 join();
<span class="lineNum">     770 </span>            :               }
<span class="lineNum">     771 </span>            :               this-&gt;base_type::wait(lk, rethrow);
<span class="lineNum">     772 </span>            :           }
<span class="lineNum">     773 </span>            :         };
<span class="lineNum">     774 </span>            : 
<span class="lineNum">     775 </span>            :         /////////////////////////
<span class="lineNum">     776 </span>            :         /// future_async_shared_state
<span class="lineNum">     777 </span>            :         /////////////////////////
<span class="lineNum">     778 </span>            :         template&lt;typename Rp, typename Fp&gt;
<span class="lineNum">     779 </span>            :         struct future_async_shared_state: future_async_shared_state_base&lt;Rp&gt;
<span class="lineNum">     780 </span>            :         {
<span class="lineNum">     781 </span>            :           future_async_shared_state()
<span class="lineNum">     782 </span>            :           {
<span class="lineNum">     783 </span>            :           }
<span class="lineNum">     784 </span>            : 
<span class="lineNum">     785 </span>            :           void init(BOOST_THREAD_FWD_REF(Fp) f)
<span class="lineNum">     786 </span>            :           {
<span class="lineNum">     787 </span>            :             shared_ptr&lt;boost::detail::shared_state_base&gt; that = this-&gt;shared_from_this();
<span class="lineNum">     788 </span>            :             this-&gt;thr_ = thread(&amp;future_async_shared_state::run, that, boost::forward&lt;Fp&gt;(f));
<span class="lineNum">     789 </span>            :           }
<span class="lineNum">     790 </span>            : 
<span class="lineNum">     791 </span>            :           static void run(shared_ptr&lt;boost::detail::shared_state_base&gt; that_, BOOST_THREAD_FWD_REF(Fp) f)
<span class="lineNum">     792 </span>            :           {
<span class="lineNum">     793 </span>            :             future_async_shared_state* that = dynamic_cast&lt;future_async_shared_state*&gt;(that_.get());
<span class="lineNum">     794 </span>            :             try
<span class="lineNum">     795 </span>            :             {
<span class="lineNum">     796 </span>            :               that-&gt;mark_finished_with_result(f());
<span class="lineNum">     797 </span>            :             }
<span class="lineNum">     798 </span>            :             catch(...)
<span class="lineNum">     799 </span>            :             {
<span class="lineNum">     800 </span>            :               that-&gt;mark_exceptional_finish();
<span class="lineNum">     801 </span>            :             }
<span class="lineNum">     802 </span>            :           }
<span class="lineNum">     803 </span>            :         };
<span class="lineNum">     804 </span>            : 
<span class="lineNum">     805 </span>            :         template&lt;typename Fp&gt;
<span class="lineNum">     806 </span>            :         struct future_async_shared_state&lt;void, Fp&gt;: public future_async_shared_state_base&lt;void&gt;
<span class="lineNum">     807 </span>            :         {
<span class="lineNum">     808 </span>            :           void init(BOOST_THREAD_FWD_REF(Fp) f)
<span class="lineNum">     809 </span>            :           {
<span class="lineNum">     810 </span>            :             this-&gt;thr_ = thread(&amp;future_async_shared_state::run, this-&gt;shared_from_this(), boost::move(f));
<span class="lineNum">     811 </span>            :           }
<span class="lineNum">     812 </span>            : 
<span class="lineNum">     813 </span>            :           static void run(shared_ptr&lt;boost::detail::shared_state_base&gt; that_, BOOST_THREAD_FWD_REF(Fp) f)
<span class="lineNum">     814 </span>            :           {
<span class="lineNum">     815 </span>            :             future_async_shared_state* that = dynamic_cast&lt;future_async_shared_state*&gt;(that_.get());
<span class="lineNum">     816 </span>            :             try
<span class="lineNum">     817 </span>            :             {
<span class="lineNum">     818 </span>            :               f();
<span class="lineNum">     819 </span>            :               that-&gt;mark_finished_with_result();
<span class="lineNum">     820 </span>            :             }
<span class="lineNum">     821 </span>            :             catch(...)
<span class="lineNum">     822 </span>            :             {
<span class="lineNum">     823 </span>            :               that-&gt;mark_exceptional_finish();
<span class="lineNum">     824 </span>            :             }
<span class="lineNum">     825 </span>            :           }
<span class="lineNum">     826 </span>            :         };
<span class="lineNum">     827 </span>            : 
<span class="lineNum">     828 </span>            :         template&lt;typename Rp, typename Fp&gt;
<span class="lineNum">     829 </span>            :         struct future_async_shared_state&lt;Rp&amp;, Fp&gt;: future_async_shared_state_base&lt;Rp&amp;&gt;
<span class="lineNum">     830 </span>            :         {
<span class="lineNum">     831 </span>            :           void init(BOOST_THREAD_FWD_REF(Fp) f)
<span class="lineNum">     832 </span>            :           {
<span class="lineNum">     833 </span>            :             this-&gt;thr_ = thread(&amp;future_async_shared_state::run, this-&gt;shared_from_this(), boost::move(f));
<span class="lineNum">     834 </span>            :           }
<span class="lineNum">     835 </span>            : 
<span class="lineNum">     836 </span>            :           static void run(shared_ptr&lt;boost::detail::shared_state_base&gt; that_, BOOST_THREAD_FWD_REF(Fp) f)
<span class="lineNum">     837 </span>            :           {
<span class="lineNum">     838 </span>            :             future_async_shared_state* that = dynamic_cast&lt;future_async_shared_state*&gt;(that_.get());
<span class="lineNum">     839 </span>            :             try
<span class="lineNum">     840 </span>            :             {
<span class="lineNum">     841 </span>            :               that-&gt;mark_finished_with_result(f());
<span class="lineNum">     842 </span>            :             }
<span class="lineNum">     843 </span>            :             catch(...)
<span class="lineNum">     844 </span>            :             {
<span class="lineNum">     845 </span>            :               that-&gt;mark_exceptional_finish();
<span class="lineNum">     846 </span>            :             }
<span class="lineNum">     847 </span>            :           }
<span class="lineNum">     848 </span>            :         };
<span class="lineNum">     849 </span>            : 
<span class="lineNum">     850 </span>            :         //////////////////////////
<span class="lineNum">     851 </span>            :         /// future_deferred_shared_state
<span class="lineNum">     852 </span>            :         //////////////////////////
<span class="lineNum">     853 </span>            :         template&lt;typename Rp, typename Fp&gt;
<span class="lineNum">     854 </span>            :         struct future_deferred_shared_state: shared_state&lt;Rp&gt;
<span class="lineNum">     855 </span>            :         {
<span class="lineNum">     856 </span>            :           typedef shared_state&lt;Rp&gt; base_type;
<span class="lineNum">     857 </span>            :           Fp func_;
<span class="lineNum">     858 </span>            : 
<span class="lineNum">     859 </span>            :         public:
<span class="lineNum">     860 </span>            :           explicit future_deferred_shared_state(BOOST_THREAD_FWD_REF(Fp) f)
<span class="lineNum">     861 </span>            :           : func_(boost::move(f))
<span class="lineNum">     862 </span>            :           {
<span class="lineNum">     863 </span>            :             this-&gt;set_deferred();
<span class="lineNum">     864 </span>            :           }
<span class="lineNum">     865 </span>            : 
<span class="lineNum">     866 </span>            :           virtual void execute(boost::unique_lock&lt;boost::mutex&gt;&amp; lck) {
<span class="lineNum">     867 </span>            :             try
<span class="lineNum">     868 </span>            :             {
<span class="lineNum">     869 </span>            :               Fp local_fuct=boost::move(func_);
<span class="lineNum">     870 </span>            :               relocker relock(lck);
<span class="lineNum">     871 </span>            :               Rp res = local_fuct();
<span class="lineNum">     872 </span>            :               relock.lock();
<span class="lineNum">     873 </span>            :               this-&gt;mark_finished_with_result_internal(boost::move(res), lck);
<span class="lineNum">     874 </span>            :             }
<span class="lineNum">     875 </span>            :             catch (...)
<span class="lineNum">     876 </span>            :             {
<span class="lineNum">     877 </span>            :               this-&gt;mark_exceptional_finish_internal(current_exception(), lck);
<span class="lineNum">     878 </span>            :             }
<span class="lineNum">     879 </span>            :           }
<span class="lineNum">     880 </span>            :         };
<span class="lineNum">     881 </span>            :         template&lt;typename Rp, typename Fp&gt;
<span class="lineNum">     882 </span>            :         struct future_deferred_shared_state&lt;Rp&amp;,Fp&gt;: shared_state&lt;Rp&amp;&gt;
<span class="lineNum">     883 </span>            :         {
<span class="lineNum">     884 </span>            :           typedef shared_state&lt;Rp&amp;&gt; base_type;
<span class="lineNum">     885 </span>            :           Fp func_;
<span class="lineNum">     886 </span>            : 
<span class="lineNum">     887 </span>            :         public:
<span class="lineNum">     888 </span>            :           explicit future_deferred_shared_state(BOOST_THREAD_FWD_REF(Fp) f)
<span class="lineNum">     889 </span>            :           : func_(boost::move(f))
<span class="lineNum">     890 </span>            :           {
<span class="lineNum">     891 </span>            :             this-&gt;set_deferred();
<span class="lineNum">     892 </span>            :           }
<span class="lineNum">     893 </span>            : 
<span class="lineNum">     894 </span>            :           virtual void execute(boost::unique_lock&lt;boost::mutex&gt;&amp; lck) {
<span class="lineNum">     895 </span>            :             try
<span class="lineNum">     896 </span>            :             {
<span class="lineNum">     897 </span>            :               this-&gt;mark_finished_with_result_internal(func_(), lck);
<span class="lineNum">     898 </span>            :             }
<span class="lineNum">     899 </span>            :             catch (...)
<span class="lineNum">     900 </span>            :             {
<span class="lineNum">     901 </span>            :               this-&gt;mark_exceptional_finish_internal(current_exception(), lck);
<span class="lineNum">     902 </span>            :             }
<span class="lineNum">     903 </span>            :           }
<span class="lineNum">     904 </span>            :         };
<span class="lineNum">     905 </span>            : 
<span class="lineNum">     906 </span>            :         template&lt;typename Fp&gt;
<span class="lineNum">     907 </span>            :         struct future_deferred_shared_state&lt;void,Fp&gt;: shared_state&lt;void&gt;
<span class="lineNum">     908 </span>            :         {
<span class="lineNum">     909 </span>            :           typedef shared_state&lt;void&gt; base_type;
<span class="lineNum">     910 </span>            :           Fp func_;
<span class="lineNum">     911 </span>            : 
<span class="lineNum">     912 </span>            :         public:
<span class="lineNum">     913 </span>            :           explicit future_deferred_shared_state(BOOST_THREAD_FWD_REF(Fp) f)
<span class="lineNum">     914 </span>            :           : func_(boost::move(f))
<span class="lineNum">     915 </span>            :           {
<span class="lineNum">     916 </span>            :             this-&gt;set_deferred();
<span class="lineNum">     917 </span>            :           }
<span class="lineNum">     918 </span>            : 
<span class="lineNum">     919 </span>            :           virtual void execute(boost::unique_lock&lt;boost::mutex&gt;&amp; lck) {
<span class="lineNum">     920 </span>            :             try
<span class="lineNum">     921 </span>            :             {
<span class="lineNum">     922 </span>            :               Fp local_fuct=boost::move(func_);
<span class="lineNum">     923 </span>            :               relocker relock(lck);
<span class="lineNum">     924 </span>            :               local_fuct();
<span class="lineNum">     925 </span>            :               relock.lock();
<span class="lineNum">     926 </span>            :               this-&gt;mark_finished_with_result_internal(lck);
<span class="lineNum">     927 </span>            :             }
<span class="lineNum">     928 </span>            :             catch (...)
<span class="lineNum">     929 </span>            :             {
<span class="lineNum">     930 </span>            :               this-&gt;mark_exceptional_finish_internal(current_exception(), lck);
<span class="lineNum">     931 </span>            :             }
<span class="lineNum">     932 </span>            :           }
<span class="lineNum">     933 </span>            :         };
<span class="lineNum">     934 </span>            : 
<span class="lineNum">     935 </span>            :         class future_waiter
<span class="lineNum">     936 </span>            :         {
<span class="lineNum">     937 </span>            :             struct registered_waiter;
<span class="lineNum">     938 </span>            :             typedef std::vector&lt;int&gt;::size_type count_type;
<span class="lineNum">     939 </span>            : 
<span class="lineNum">     940 </span>            :             struct registered_waiter
<span class="lineNum">     941 </span>            :             {
<span class="lineNum">     942 </span>            :                 boost::shared_ptr&lt;detail::shared_state_base&gt; future_;
<span class="lineNum">     943 </span>            :                 detail::shared_state_base::notify_when_ready_handle handle;
<span class="lineNum">     944 </span>            :                 count_type index;
<span class="lineNum">     945 </span>            : 
<span class="lineNum">     946 </span>            :                 registered_waiter(boost::shared_ptr&lt;detail::shared_state_base&gt; const&amp; a_future,
<span class="lineNum">     947 </span>            :                                   detail::shared_state_base::notify_when_ready_handle handle_,
<span class="lineNum">     948 </span>            :                                   count_type index_):
<span class="lineNum">     949 </span>            :                     future_(a_future),handle(handle_),index(index_)
<span class="lineNum">     950 </span>            :                 {}
<span class="lineNum">     951 </span>            :             };
<span class="lineNum">     952 </span>            : 
<span class="lineNum">     953 </span>            :             struct all_futures_lock
<span class="lineNum">     954 </span>            :             {
<span class="lineNum">     955 </span>            : #ifdef _MANAGED
<span class="lineNum">     956 </span>            :                    typedef std::ptrdiff_t count_type_portable;
<span class="lineNum">     957 </span>            : #else
<span class="lineNum">     958 </span>            :                    typedef count_type count_type_portable;
<span class="lineNum">     959 </span>            : #endif
<span class="lineNum">     960 </span>            :                    count_type_portable count;
<span class="lineNum">     961 </span>            :                    boost::scoped_array&lt;boost::unique_lock&lt;boost::mutex&gt; &gt; locks;
<span class="lineNum">     962 </span>            : 
<span class="lineNum">     963 </span>            :                 all_futures_lock(std::vector&lt;registered_waiter&gt;&amp; futures):
<span class="lineNum">     964 </span>            :                     count(futures.size()),locks(new boost::unique_lock&lt;boost::mutex&gt;[count])
<span class="lineNum">     965 </span>            :                 {
<span class="lineNum">     966 </span>            :                     for(count_type_portable i=0;i&lt;count;++i)
<span class="lineNum">     967 </span>            :                     {
<span class="lineNum">     968 </span>            :                         locks[i]=BOOST_THREAD_MAKE_RV_REF(boost::unique_lock&lt;boost::mutex&gt;(futures[i].future_-&gt;mutex));
<span class="lineNum">     969 </span>            :                     }
<span class="lineNum">     970 </span>            :                 }
<span class="lineNum">     971 </span>            : 
<span class="lineNum">     972 </span>            :                 void lock()
<span class="lineNum">     973 </span>            :                 {
<span class="lineNum">     974 </span>            :                     boost::lock(locks.get(),locks.get()+count);
<span class="lineNum">     975 </span>            :                 }
<span class="lineNum">     976 </span>            : 
<span class="lineNum">     977 </span>            :                 void unlock()
<span class="lineNum">     978 </span>            :                 {
<span class="lineNum">     979 </span>            :                     for(count_type_portable i=0;i&lt;count;++i)
<span class="lineNum">     980 </span>            :                     {
<span class="lineNum">     981 </span>            :                         locks[i].unlock();
<span class="lineNum">     982 </span>            :                     }
<span class="lineNum">     983 </span>            :                 }
<span class="lineNum">     984 </span>            :             };
<span class="lineNum">     985 </span>            : 
<span class="lineNum">     986 </span>            :             boost::condition_variable_any cv;
<span class="lineNum">     987 </span>            :             std::vector&lt;registered_waiter&gt; futures_;
<span class="lineNum">     988 </span>            :             count_type future_count;
<span class="lineNum">     989 </span>            : 
<span class="lineNum">     990 </span>            :         public:
<span class="lineNum">     991 </span>            :             future_waiter():
<span class="lineNum">     992 </span>            :                 future_count(0)
<span class="lineNum">     993 </span>            :             {}
<span class="lineNum">     994 </span>            : 
<span class="lineNum">     995 </span>            :             template&lt;typename F&gt;
<span class="lineNum">     996 </span>            :             void add(F&amp; f)
<span class="lineNum">     997 </span>            :             {
<span class="lineNum">     998 </span>            :                 if(f.future_)
<span class="lineNum">     999 </span>            :                 {
<span class="lineNum">    1000 </span>            :                   registered_waiter waiter(f.future_,f.future_-&gt;notify_when_ready(cv),future_count);
<span class="lineNum">    1001 </span>            :                   try {
<span class="lineNum">    1002 </span>            :                     futures_.push_back(waiter);
<span class="lineNum">    1003 </span>            :                   } catch(...) {
<span class="lineNum">    1004 </span>            :                     f.future_-&gt;unnotify_when_ready(waiter.handle);
<span class="lineNum">    1005 </span>            :                     throw;
<span class="lineNum">    1006 </span>            :                   }
<span class="lineNum">    1007 </span>            :                 }
<span class="lineNum">    1008 </span>            :                 ++future_count;
<span class="lineNum">    1009 </span>            :             }
<span class="lineNum">    1010 </span>            : 
<span class="lineNum">    1011 </span>            : #ifndef BOOST_NO_CXX11_VARIADIC_TEMPLATES
<span class="lineNum">    1012 </span>            :             template&lt;typename F1, typename... Fs&gt;
<span class="lineNum">    1013 </span>            :             void add(F1&amp; f1, Fs&amp;... fs)
<span class="lineNum">    1014 </span>            :             {
<span class="lineNum">    1015 </span>            :               add(f1); add(fs...);
<span class="lineNum">    1016 </span>            :             }
<span class="lineNum">    1017 </span>            : #endif
<span class="lineNum">    1018 </span>            : 
<span class="lineNum">    1019 </span>            :             count_type wait()
<span class="lineNum">    1020 </span>            :             {
<span class="lineNum">    1021 </span>            :                 all_futures_lock lk(futures_);
<span class="lineNum">    1022 </span>            :                 for(;;)
<span class="lineNum">    1023 </span>            :                 {
<span class="lineNum">    1024 </span>            :                     for(count_type i=0;i&lt;futures_.size();++i)
<span class="lineNum">    1025 </span>            :                     {
<span class="lineNum">    1026 </span>            :                         if(futures_[i].future_-&gt;done)
<span class="lineNum">    1027 </span>            :                         {
<span class="lineNum">    1028 </span>            :                             return futures_[i].index;
<span class="lineNum">    1029 </span>            :                         }
<span class="lineNum">    1030 </span>            :                     }
<span class="lineNum">    1031 </span>            :                     cv.wait(lk);
<span class="lineNum">    1032 </span>            :                 }
<span class="lineNum">    1033 </span>            :             }
<span class="lineNum">    1034 </span>            : 
<span class="lineNum">    1035 </span>            :             ~future_waiter()
<span class="lineNum">    1036 </span>            :             {
<span class="lineNum">    1037 </span>            :                 for(count_type i=0;i&lt;futures_.size();++i)
<span class="lineNum">    1038 </span>            :                 {
<span class="lineNum">    1039 </span>            :                     futures_[i].future_-&gt;unnotify_when_ready(futures_[i].handle);
<span class="lineNum">    1040 </span>            :                 }
<span class="lineNum">    1041 </span>            :             }
<span class="lineNum">    1042 </span>            :         };
<span class="lineNum">    1043 </span>            : 
<span class="lineNum">    1044 </span>            :     }
<span class="lineNum">    1045 </span>            : 
<span class="lineNum">    1046 </span>            :     template &lt;typename R&gt;
<span class="lineNum">    1047 </span>            :     class BOOST_THREAD_FUTURE;
<span class="lineNum">    1048 </span>            : 
<span class="lineNum">    1049 </span>            :     template &lt;typename R&gt;
<span class="lineNum">    1050 </span>            :     class shared_future;
<span class="lineNum">    1051 </span>            : 
<span class="lineNum">    1052 </span>            :     template&lt;typename T&gt;
<span class="lineNum">    1053 </span>            :     struct is_future_type&lt;BOOST_THREAD_FUTURE&lt;T&gt; &gt; : true_type
<span class="lineNum">    1054 </span>            :     {
<span class="lineNum">    1055 </span>            :     };
<span class="lineNum">    1056 </span>            : 
<span class="lineNum">    1057 </span>            :     template&lt;typename T&gt;
<span class="lineNum">    1058 </span>            :     struct is_future_type&lt;shared_future&lt;T&gt; &gt; : true_type
<span class="lineNum">    1059 </span>            :     {
<span class="lineNum">    1060 </span>            :     };
<span class="lineNum">    1061 </span>            : 
<span class="lineNum">    1062 </span>            : //    template&lt;typename Iterator&gt;
<span class="lineNum">    1063 </span>            : //    typename boost::disable_if&lt;is_future_type&lt;Iterator&gt;,Iterator&gt;::type wait_for_any(Iterator begin,Iterator end)
<span class="lineNum">    1064 </span>            : //    {
<span class="lineNum">    1065 </span>            : //        if(begin==end)
<span class="lineNum">    1066 </span>            : //            return end;
<span class="lineNum">    1067 </span>            : //
<span class="lineNum">    1068 </span>            : //        detail::future_waiter waiter;
<span class="lineNum">    1069 </span>            : //        for(Iterator current=begin;current!=end;++current)
<span class="lineNum">    1070 </span>            : //        {
<span class="lineNum">    1071 </span>            : //            waiter.add(*current);
<span class="lineNum">    1072 </span>            : //        }
<span class="lineNum">    1073 </span>            : //        return boost::next(begin,waiter.wait());
<span class="lineNum">    1074 </span>            : //    }
<span class="lineNum">    1075 </span>            : 
<span class="lineNum">    1076 </span>            : #ifdef BOOST_NO_CXX11_VARIADIC_TEMPLATES
<span class="lineNum">    1077 </span>            :     template&lt;typename F1,typename F2&gt;
<span class="lineNum">    1078 </span>            :     typename boost::enable_if&lt;is_future_type&lt;F1&gt;,unsigned&gt;::type wait_for_any(F1&amp; f1,F2&amp; f2)
<span class="lineNum">    1079 </span>            :     {
<span class="lineNum">    1080 </span>            :         detail::future_waiter waiter;
<span class="lineNum">    1081 </span>            :         waiter.add(f1);
<span class="lineNum">    1082 </span>            :         waiter.add(f2);
<span class="lineNum">    1083 </span>            :         return waiter.wait();
<span class="lineNum">    1084 </span>            :     }
<span class="lineNum">    1085 </span>            : 
<span class="lineNum">    1086 </span>            :     template&lt;typename F1,typename F2,typename F3&gt;
<span class="lineNum">    1087 </span>            :     unsigned wait_for_any(F1&amp; f1,F2&amp; f2,F3&amp; f3)
<span class="lineNum">    1088 </span>            :     {
<span class="lineNum">    1089 </span>            :         detail::future_waiter waiter;
<span class="lineNum">    1090 </span>            :         waiter.add(f1);
<span class="lineNum">    1091 </span>            :         waiter.add(f2);
<span class="lineNum">    1092 </span>            :         waiter.add(f3);
<span class="lineNum">    1093 </span>            :         return waiter.wait();
<span class="lineNum">    1094 </span>            :     }
<span class="lineNum">    1095 </span>            : 
<span class="lineNum">    1096 </span>            :     template&lt;typename F1,typename F2,typename F3,typename F4&gt;
<span class="lineNum">    1097 </span>            :     unsigned wait_for_any(F1&amp; f1,F2&amp; f2,F3&amp; f3,F4&amp; f4)
<span class="lineNum">    1098 </span>            :     {
<span class="lineNum">    1099 </span>            :         detail::future_waiter waiter;
<span class="lineNum">    1100 </span>            :         waiter.add(f1);
<span class="lineNum">    1101 </span>            :         waiter.add(f2);
<span class="lineNum">    1102 </span>            :         waiter.add(f3);
<span class="lineNum">    1103 </span>            :         waiter.add(f4);
<span class="lineNum">    1104 </span>            :         return waiter.wait();
<span class="lineNum">    1105 </span>            :     }
<span class="lineNum">    1106 </span>            : 
<span class="lineNum">    1107 </span>            :     template&lt;typename F1,typename F2,typename F3,typename F4,typename F5&gt;
<span class="lineNum">    1108 </span>            :     unsigned wait_for_any(F1&amp; f1,F2&amp; f2,F3&amp; f3,F4&amp; f4,F5&amp; f5)
<span class="lineNum">    1109 </span>            :     {
<span class="lineNum">    1110 </span>            :         detail::future_waiter waiter;
<span class="lineNum">    1111 </span>            :         waiter.add(f1);
<span class="lineNum">    1112 </span>            :         waiter.add(f2);
<span class="lineNum">    1113 </span>            :         waiter.add(f3);
<span class="lineNum">    1114 </span>            :         waiter.add(f4);
<span class="lineNum">    1115 </span>            :         waiter.add(f5);
<span class="lineNum">    1116 </span>            :         return waiter.wait();
<span class="lineNum">    1117 </span>            :     }
<span class="lineNum">    1118 </span>            : #else
<span class="lineNum">    1119 </span>            :     template&lt;typename F1, typename... Fs&gt;
<span class="lineNum">    1120 </span>            :     typename boost::enable_if&lt;is_future_type&lt;F1&gt;, unsigned&gt;::type wait_for_any(F1&amp; f1, Fs&amp;... fs)
<span class="lineNum">    1121 </span>            :     {
<span class="lineNum">    1122 </span>            :       detail::future_waiter waiter;
<span class="lineNum">    1123 </span>            :       waiter.add(f1, fs...);
<span class="lineNum">    1124 </span>            :       return waiter.wait();
<span class="lineNum">    1125 </span>            :     }
<span class="lineNum">    1126 </span>            : #endif // !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
<span class="lineNum">    1127 </span>            : 
<span class="lineNum">    1128 </span>            :     template &lt;typename R&gt;
<span class="lineNum">    1129 </span>            :     class promise;
<span class="lineNum">    1130 </span>            : 
<span class="lineNum">    1131 </span>            :     template &lt;typename R&gt;
<span class="lineNum">    1132 </span>            :     class packaged_task;
<span class="lineNum">    1133 </span>            : 
<span class="lineNum">    1134 </span>            :     namespace detail
<span class="lineNum">    1135 </span>            :     {
<span class="lineNum">    1136 </span>            :       /// Common implementation for all the futures independently of the return type
<span class="lineNum">    1137 </span>            :       class base_future
<span class="lineNum">    1138 </span>            :       {
<span class="lineNum">    1139 </span>            :       public:
<span class="lineNum">    1140 </span>            :       };
<span class="lineNum">    1141 </span>            :       /// Common implementation for future and shared_future.
<span class="lineNum">    1142 </span>            :       template &lt;typename R&gt;
<span class="lineNum">    1143 </span>            :       class basic_future : public base_future
<span class="lineNum">    1144 </span>            :       {
<span class="lineNum">    1145 </span>            :       protected:
<span class="lineNum">    1146 </span>            :       public:
<span class="lineNum">    1147 </span>            : 
<span class="lineNum">    1148 </span>            :         typedef boost::shared_ptr&lt;detail::shared_state&lt;R&gt; &gt; future_ptr;
<span class="lineNum">    1149 </span>            :         typedef typename detail::shared_state&lt;R&gt;::move_dest_type move_dest_type;
<span class="lineNum">    1150 </span>            : 
<span class="lineNum">    1151 </span>            :         static //BOOST_CONSTEXPR
<span class="lineNum">    1152 </span>            :         future_ptr make_exceptional_future_ptr(exceptional_ptr const&amp; ex) {
<span class="lineNum">    1153 </span>            :           promise&lt;R&gt; p;
<span class="lineNum">    1154 </span>            :           p.set_exception(ex.ptr_);
<span class="lineNum">    1155 </span>            :           return p.get_future().future_;
<span class="lineNum">    1156 </span>            :         }
<span class="lineNum">    1157 </span>            : 
<span class="lineNum">    1158 </span>            :         void set_exceptional_if_invalid() {
<span class="lineNum">    1159 </span>            :           if (valid()) return;
<span class="lineNum">    1160 </span>            :           promise&lt;R&gt; p;
<span class="lineNum">    1161 </span>            :           p.set_exception(future_uninitialized());
<span class="lineNum">    1162 </span>            :           future_ = p.get_future().future_;
<span class="lineNum">    1163 </span>            :         }
<span class="lineNum">    1164 </span>            : 
<span class="lineNum">    1165 </span>            :         future_ptr future_;
<span class="lineNum">    1166 </span>            : 
<span class="lineNum">    1167 </span>            :         basic_future(future_ptr a_future):
<span class="lineNum">    1168 </span>            :           future_(a_future)
<span class="lineNum">    1169 </span>            :         {
<span class="lineNum">    1170 </span>            :           if (a_future) a_future-&gt;inc();
<span class="lineNum">    1171 </span>            :         }
<span class="lineNum">    1172 </span>            : 
<span class="lineNum">    1173 </span>            :       public:
<span class="lineNum">    1174 </span>            :         typedef future_state::state state;
<span class="lineNum">    1175 </span>            : 
<span class="lineNum">    1176 </span>            :         BOOST_THREAD_MOVABLE_ONLY(basic_future)
<span class="lineNum">    1177 </span>            :         basic_future(): future_() {}
<span class="lineNum">    1178 </span>            : 
<span class="lineNum">    1179 </span>            : 
<span class="lineNum">    1180 </span>            :         //BOOST_CONSTEXPR
<span class="lineNum">    1181 </span>            :         basic_future(exceptional_ptr const&amp; ex)
<span class="lineNum">    1182 </span>            :           : future_(make_exceptional_future_ptr(ex))
<span class="lineNum">    1183 </span>            :         {
<span class="lineNum">    1184 </span>            :           future_-&gt;inc();
<span class="lineNum">    1185 </span>            :         }
<span class="lineNum">    1186 </span>            : 
<span class="lineNum">    1187 </span>            :         ~basic_future() {
<span class="lineNum">    1188 </span>            :           if (future_) future_-&gt;dec();
<span class="lineNum">    1189 </span>            :         }
<span class="lineNum">    1190 </span>            : 
<span class="lineNum">    1191 </span>            :         basic_future(BOOST_THREAD_RV_REF(basic_future) other) BOOST_NOEXCEPT:
<span class="lineNum">    1192 </span>            :         future_(BOOST_THREAD_RV(other).future_)
<span class="lineNum">    1193 </span>            :         {
<span class="lineNum">    1194 </span>            :             BOOST_THREAD_RV(other).future_.reset();
<span class="lineNum">    1195 </span>            :         }
<span class="lineNum">    1196 </span>            :         basic_future&amp; operator=(BOOST_THREAD_RV_REF(basic_future) other) BOOST_NOEXCEPT
<span class="lineNum">    1197 </span>            :         {
<span class="lineNum">    1198 </span>            :             if (this-&gt;future_) {
<span class="lineNum">    1199 </span>            :               this-&gt;future_-&gt;dec();
<span class="lineNum">    1200 </span>            :             }
<span class="lineNum">    1201 </span>            :             future_=BOOST_THREAD_RV(other).future_;
<span class="lineNum">    1202 </span>            :             BOOST_THREAD_RV(other).future_.reset();
<span class="lineNum">    1203 </span>            :             return *this;
<span class="lineNum">    1204 </span>            :         }
<span class="lineNum">    1205 </span>            :         void swap(basic_future&amp; that) BOOST_NOEXCEPT
<span class="lineNum">    1206 </span>            :         {
<span class="lineNum">    1207 </span>            :           future_.swap(that.future_);
<span class="lineNum">    1208 </span>            :         }
<span class="lineNum">    1209 </span>            :         // functions to check state, and wait for ready
<span class="lineNum">    1210 </span>            :         state get_state(boost::unique_lock&lt;boost::mutex&gt;&amp; lk) const
<span class="lineNum">    1211 </span>            :         {
<span class="lineNum">    1212 </span>            :             if(!future_)
<span class="lineNum">    1213 </span>            :             {
<span class="lineNum">    1214 </span>            :                 return future_state::uninitialized;
<span class="lineNum">    1215 </span>            :             }
<span class="lineNum">    1216 </span>            :             return future_-&gt;get_state(lk);
<span class="lineNum">    1217 </span>            :         }
<span class="lineNum">    1218 </span>            :         state get_state() const
<span class="lineNum">    1219 </span>            :         {
<span class="lineNum">    1220 </span>            :             if(!future_)
<span class="lineNum">    1221 </span>            :             {
<span class="lineNum">    1222 </span>            :                 return future_state::uninitialized;
<span class="lineNum">    1223 </span>            :             }
<span class="lineNum">    1224 </span>            :             return future_-&gt;get_state();
<span class="lineNum">    1225 </span>            :         }
<span class="lineNum">    1226 </span>            : 
<span class="lineNum">    1227 </span>            :         bool is_ready() const
<span class="lineNum">    1228 </span>            :         {
<span class="lineNum">    1229 </span>            :             return get_state()==future_state::ready;
<span class="lineNum">    1230 </span>            :         }
<span class="lineNum">    1231 </span>            : 
<span class="lineNum">    1232 </span>            :         bool is_ready(boost::unique_lock&lt;boost::mutex&gt;&amp; lk) const
<span class="lineNum">    1233 </span>            :         {
<span class="lineNum">    1234 </span>            :             return get_state(lk)==future_state::ready;
<span class="lineNum">    1235 </span>            :         }
<span class="lineNum">    1236 </span>            :         bool has_exception() const
<span class="lineNum">    1237 </span>            :         {
<span class="lineNum">    1238 </span>            :             return future_ &amp;&amp; future_-&gt;has_exception();
<span class="lineNum">    1239 </span>            :         }
<span class="lineNum">    1240 </span>            : 
<span class="lineNum">    1241 </span>            :         bool has_value() const
<span class="lineNum">    1242 </span>            :         {
<span class="lineNum">    1243 </span>            :             return future_ &amp;&amp; future_-&gt;has_value();
<span class="lineNum">    1244 </span>            :         }
<span class="lineNum">    1245 </span>            : 
<span class="lineNum">    1246 </span>            :         launch launch_policy(boost::unique_lock&lt;boost::mutex&gt;&amp; lk) const
<span class="lineNum">    1247 </span>            :         {
<span class="lineNum">    1248 </span>            :             if ( future_ ) return future_-&gt;launch_policy(lk);
<span class="lineNum">    1249 </span>            :             else return launch(launch::none);
<span class="lineNum">    1250 </span>            :         }
<span class="lineNum">    1251 </span>            : 
<span class="lineNum">    1252 </span>            :         exception_ptr get_exception_ptr()
<span class="lineNum">    1253 </span>            :         {
<span class="lineNum">    1254 </span>            :             return future_
<span class="lineNum">    1255 </span>            :                 ? future_-&gt;get_exception_ptr()
<span class="lineNum">    1256 </span>            :                 : exception_ptr();
<span class="lineNum">    1257 </span>            :         }
<span class="lineNum">    1258 </span>            : 
<span class="lineNum">    1259 </span>            :         bool valid() const BOOST_NOEXCEPT
<span class="lineNum">    1260 </span>            :         {
<span class="lineNum">    1261 </span>            :             return future_ != 0 &amp;&amp; future_-&gt;valid();
<span class="lineNum">    1262 </span>            :         }
<span class="lineNum">    1263 </span>            : 
<span class="lineNum">    1264 </span>            :         void wait() const
<span class="lineNum">    1265 </span>            :         {
<span class="lineNum">    1266 </span>            :             if(!future_)
<span class="lineNum">    1267 </span>            :             {
<span class="lineNum">    1268 </span>            :                 boost::throw_exception(future_uninitialized());
<span class="lineNum">    1269 </span>            :             }
<span class="lineNum">    1270 </span>            :             future_-&gt;wait(false);
<span class="lineNum">    1271 </span>            :         }
<span class="lineNum">    1272 </span>            : 
<span class="lineNum">    1273 </span>            :         typedef detail::shared_state_base::notify_when_ready_handle notify_when_ready_handle;
<span class="lineNum">    1274 </span>            : 
<span class="lineNum">    1275 </span>            :         boost::mutex&amp; mutex() {
<span class="lineNum">    1276 </span>            :           if(!future_)
<span class="lineNum">    1277 </span>            :           {
<span class="lineNum">    1278 </span>            :               boost::throw_exception(future_uninitialized());
<span class="lineNum">    1279 </span>            :           }
<span class="lineNum">    1280 </span>            :           return future_-&gt;mutex;
<span class="lineNum">    1281 </span>            :         };
<span class="lineNum">    1282 </span>            : 
<span class="lineNum">    1283 </span>            :         notify_when_ready_handle notify_when_ready(boost::condition_variable_any&amp; cv)
<span class="lineNum">    1284 </span>            :         {
<span class="lineNum">    1285 </span>            :           if(!future_)
<span class="lineNum">    1286 </span>            :           {
<span class="lineNum">    1287 </span>            :               boost::throw_exception(future_uninitialized());
<span class="lineNum">    1288 </span>            :           }
<span class="lineNum">    1289 </span>            :           return future_-&gt;notify_when_ready(cv);
<span class="lineNum">    1290 </span>            :         }
<span class="lineNum">    1291 </span>            : 
<span class="lineNum">    1292 </span>            :         void unnotify_when_ready(notify_when_ready_handle h)
<span class="lineNum">    1293 </span>            :         {
<span class="lineNum">    1294 </span>            :           if(!future_)
<span class="lineNum">    1295 </span>            :           {
<span class="lineNum">    1296 </span>            :               boost::throw_exception(future_uninitialized());
<span class="lineNum">    1297 </span>            :           }
<span class="lineNum">    1298 </span>            :           return future_-&gt;unnotify_when_ready(h);
<span class="lineNum">    1299 </span>            :         }
<span class="lineNum">    1300 </span>            : 
<span class="lineNum">    1301 </span>            : #if defined BOOST_THREAD_USES_DATETIME
<span class="lineNum">    1302 </span>            :         template&lt;typename Duration&gt;
<span class="lineNum">    1303 </span>            :         bool timed_wait(Duration const&amp; rel_time) const
<span class="lineNum">    1304 </span>            :         {
<span class="lineNum">    1305 </span>            :             return timed_wait_until(boost::get_system_time()+rel_time);
<span class="lineNum">    1306 </span>            :         }
<span class="lineNum">    1307 </span>            : 
<span class="lineNum">    1308 </span>            :         bool timed_wait_until(boost::system_time const&amp; abs_time) const
<span class="lineNum">    1309 </span>            :         {
<span class="lineNum">    1310 </span>            :             if(!future_)
<span class="lineNum">    1311 </span>            :             {
<span class="lineNum">    1312 </span>            :                 boost::throw_exception(future_uninitialized());
<span class="lineNum">    1313 </span>            :             }
<span class="lineNum">    1314 </span>            :             return future_-&gt;timed_wait_until(abs_time);
<span class="lineNum">    1315 </span>            :         }
<span class="lineNum">    1316 </span>            : #endif
<span class="lineNum">    1317 </span>            : #ifdef BOOST_THREAD_USES_CHRONO
<span class="lineNum">    1318 </span>            :         template &lt;class Rep, class Period&gt;
<span class="lineNum">    1319 </span>            :         future_status
<span class="lineNum">    1320 </span>            :         wait_for(const chrono::duration&lt;Rep, Period&gt;&amp; rel_time) const
<span class="lineNum">    1321 </span>            :         {
<span class="lineNum">    1322 </span>            :           return wait_until(chrono::steady_clock::now() + rel_time);
<span class="lineNum">    1323 </span>            : 
<span class="lineNum">    1324 </span>            :         }
<span class="lineNum">    1325 </span>            :         template &lt;class Clock, class Duration&gt;
<span class="lineNum">    1326 </span>            :         future_status
<span class="lineNum">    1327 </span>            :         wait_until(const chrono::time_point&lt;Clock, Duration&gt;&amp; abs_time) const
<span class="lineNum">    1328 </span>            :         {
<span class="lineNum">    1329 </span>            :           if(!future_)
<span class="lineNum">    1330 </span>            :           {
<span class="lineNum">    1331 </span>            :               boost::throw_exception(future_uninitialized());
<span class="lineNum">    1332 </span>            :           }
<span class="lineNum">    1333 </span>            :           return future_-&gt;wait_until(abs_time);
<span class="lineNum">    1334 </span>            :         }
<span class="lineNum">    1335 </span>            : #endif
<span class="lineNum">    1336 </span>            : 
<span class="lineNum">    1337 </span>            :       };
<span class="lineNum">    1338 </span>            : 
<span class="lineNum">    1339 </span>            :     } // detail
<span class="lineNum">    1340 </span>            :     BOOST_THREAD_DCL_MOVABLE_BEG(R) detail::basic_future&lt;R&gt; BOOST_THREAD_DCL_MOVABLE_END
<span class="lineNum">    1341 </span>            : 
<span class="lineNum">    1342 </span>            :     namespace detail
<span class="lineNum">    1343 </span>            :     {
<span class="lineNum">    1344 </span>            : #if (!defined _MSC_VER || _MSC_VER &gt;= 1400) // _MSC_VER == 1400 on MSVC 2005
<span class="lineNum">    1345 </span>            :         template &lt;class Rp, class Fp&gt;
<span class="lineNum">    1346 </span>            :         BOOST_THREAD_FUTURE&lt;Rp&gt;
<span class="lineNum">    1347 </span>            :         make_future_async_shared_state(BOOST_THREAD_FWD_REF(Fp) f);
<span class="lineNum">    1348 </span>            : 
<span class="lineNum">    1349 </span>            :         template &lt;class Rp, class Fp&gt;
<span class="lineNum">    1350 </span>            :         BOOST_THREAD_FUTURE&lt;Rp&gt;
<span class="lineNum">    1351 </span>            :         make_future_deferred_shared_state(BOOST_THREAD_FWD_REF(Fp) f);
<span class="lineNum">    1352 </span>            : #endif // #if (!defined _MSC_VER || _MSC_VER &gt;= 1400)
<span class="lineNum">    1353 </span>            : #if defined BOOST_THREAD_PROVIDES_FUTURE_CONTINUATION
<span class="lineNum">    1354 </span>            :         template&lt;typename F, typename Rp, typename Fp&gt;
<span class="lineNum">    1355 </span>            :         struct future_deferred_continuation_shared_state;
<span class="lineNum">    1356 </span>            :         template&lt;typename F, typename Rp, typename Fp&gt;
<span class="lineNum">    1357 </span>            :         struct future_async_continuation_shared_state;
<span class="lineNum">    1358 </span>            : 
<span class="lineNum">    1359 </span>            :         template &lt;class F, class Rp, class Fp&gt;
<span class="lineNum">    1360 </span>            :         BOOST_THREAD_FUTURE&lt;Rp&gt;
<span class="lineNum">    1361 </span>            :         make_future_async_continuation_shared_state(boost::unique_lock&lt;boost::mutex&gt; &amp;lock, BOOST_THREAD_RV_REF(F) f, BOOST_THREAD_FWD_REF(Fp) c);
<span class="lineNum">    1362 </span>            : 
<span class="lineNum">    1363 </span>            :         template &lt;class F, class Rp, class Fp&gt;
<span class="lineNum">    1364 </span>            :         BOOST_THREAD_FUTURE&lt;Rp&gt;
<span class="lineNum">    1365 </span>            :         make_future_deferred_continuation_shared_state(boost::unique_lock&lt;boost::mutex&gt; &amp;lock, BOOST_THREAD_RV_REF(F) f, BOOST_THREAD_FWD_REF(Fp) c);
<span class="lineNum">    1366 </span>            : #endif
<span class="lineNum">    1367 </span>            : #if defined BOOST_THREAD_PROVIDES_FUTURE_UNWRAP
<span class="lineNum">    1368 </span>            :         template&lt;typename F, typename Rp&gt;
<span class="lineNum">    1369 </span>            :         struct future_unwrap_shared_state;
<span class="lineNum">    1370 </span>            :         template &lt;class F, class Rp&gt;
<span class="lineNum">    1371 </span>            :         inline BOOST_THREAD_FUTURE&lt;Rp&gt;
<span class="lineNum">    1372 </span>            :         make_future_unwrap_shared_state(boost::unique_lock&lt;boost::mutex&gt; &amp;lock, BOOST_THREAD_RV_REF(F) f);
<span class="lineNum">    1373 </span>            : #endif
<span class="lineNum">    1374 </span>            :     }
<span class="lineNum">    1375 </span>            : 
<span class="lineNum">    1376 </span>            :     template &lt;typename R&gt;
<span class="lineNum">    1377 </span>            :     class BOOST_THREAD_FUTURE : public detail::basic_future&lt;R&gt;
<span class="lineNum">    1378 </span>            :     {
<span class="lineNum">    1379 </span>            :     private:
<span class="lineNum">    1380 </span>            :         typedef detail::basic_future&lt;R&gt; base_type;
<span class="lineNum">    1381 </span>            :         typedef typename base_type::future_ptr future_ptr;
<span class="lineNum">    1382 </span>            : 
<span class="lineNum">    1383 </span>            :         friend class shared_future&lt;R&gt;;
<span class="lineNum">    1384 </span>            :         friend class promise&lt;R&gt;;
<span class="lineNum">    1385 </span>            : #if defined BOOST_THREAD_PROVIDES_FUTURE_CONTINUATION
<span class="lineNum">    1386 </span>            :         template &lt;typename, typename, typename&gt;
<span class="lineNum">    1387 </span>            :         friend struct detail::future_async_continuation_shared_state;
<span class="lineNum">    1388 </span>            :         template &lt;typename, typename, typename&gt;
<span class="lineNum">    1389 </span>            :         friend struct detail::future_deferred_continuation_shared_state;
<span class="lineNum">    1390 </span>            : 
<span class="lineNum">    1391 </span>            :         template &lt;class F, class Rp, class Fp&gt;
<span class="lineNum">    1392 </span>            :         friend BOOST_THREAD_FUTURE&lt;Rp&gt;
<span class="lineNum">    1393 </span>            :         detail::make_future_async_continuation_shared_state(boost::unique_lock&lt;boost::mutex&gt; &amp;lock, BOOST_THREAD_RV_REF(F) f, BOOST_THREAD_FWD_REF(Fp) c);
<span class="lineNum">    1394 </span>            : 
<span class="lineNum">    1395 </span>            :         template &lt;class F, class Rp, class Fp&gt;
<span class="lineNum">    1396 </span>            :         friend BOOST_THREAD_FUTURE&lt;Rp&gt;
<span class="lineNum">    1397 </span>            :         detail::make_future_deferred_continuation_shared_state(boost::unique_lock&lt;boost::mutex&gt; &amp;lock, BOOST_THREAD_RV_REF(F) f, BOOST_THREAD_FWD_REF(Fp) c);
<span class="lineNum">    1398 </span>            : #endif
<span class="lineNum">    1399 </span>            : #if defined BOOST_THREAD_PROVIDES_FUTURE_UNWRAP
<span class="lineNum">    1400 </span>            :         template&lt;typename F, typename Rp&gt;
<span class="lineNum">    1401 </span>            :         friend struct detail::future_unwrap_shared_state;
<span class="lineNum">    1402 </span>            :         template &lt;class F, class Rp&gt;
<span class="lineNum">    1403 </span>            :         friend BOOST_THREAD_FUTURE&lt;Rp&gt;
<span class="lineNum">    1404 </span>            :         detail::make_future_unwrap_shared_state(boost::unique_lock&lt;boost::mutex&gt; &amp;lock, BOOST_THREAD_RV_REF(F) f);
<span class="lineNum">    1405 </span>            : #endif
<span class="lineNum">    1406 </span>            : #if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK
<span class="lineNum">    1407 </span>            :         template &lt;class&gt; friend class packaged_task; // todo check if this works in windows
<span class="lineNum">    1408 </span>            : #else
<span class="lineNum">    1409 </span>            :         friend class packaged_task&lt;R&gt;;
<span class="lineNum">    1410 </span>            : #endif
<span class="lineNum">    1411 </span>            :         friend class detail::future_waiter;
<span class="lineNum">    1412 </span>            : 
<span class="lineNum">    1413 </span>            :         template &lt;class Rp, class Fp&gt;
<span class="lineNum">    1414 </span>            :         friend BOOST_THREAD_FUTURE&lt;Rp&gt;
<span class="lineNum">    1415 </span>            :         detail::make_future_async_shared_state(BOOST_THREAD_FWD_REF(Fp) f);
<span class="lineNum">    1416 </span>            : 
<span class="lineNum">    1417 </span>            :         template &lt;class Rp, class Fp&gt;
<span class="lineNum">    1418 </span>            :         friend BOOST_THREAD_FUTURE&lt;Rp&gt;
<span class="lineNum">    1419 </span>            :         detail::make_future_deferred_shared_state(BOOST_THREAD_FWD_REF(Fp) f);
<span class="lineNum">    1420 </span>            : 
<span class="lineNum">    1421 </span>            : 
<span class="lineNum">    1422 </span>            :         typedef typename base_type::move_dest_type move_dest_type;
<span class="lineNum">    1423 </span>            :     public: // when_all
<span class="lineNum">    1424 </span>            : 
<span class="lineNum">    1425 </span>            :         BOOST_THREAD_FUTURE(future_ptr a_future):
<span class="lineNum">    1426 </span>            :           base_type(a_future)
<span class="lineNum">    1427 </span>            :         {
<span class="lineNum">    1428 </span>            :         }
<span class="lineNum">    1429 </span>            : 
<span class="lineNum">    1430 </span>            :     public:
<span class="lineNum">    1431 </span>            :         BOOST_THREAD_MOVABLE_ONLY(BOOST_THREAD_FUTURE)
<span class="lineNum">    1432 </span>            :         typedef future_state::state state;
<span class="lineNum">    1433 </span>            :         typedef R value_type; // EXTENSION
<span class="lineNum">    1434 </span>            : 
<span class="lineNum">    1435 </span>            :         BOOST_CONSTEXPR BOOST_THREAD_FUTURE() {}
<span class="lineNum">    1436 </span>            :         //BOOST_CONSTEXPR
<span class="lineNum">    1437 </span>            :         BOOST_THREAD_FUTURE(exceptional_ptr const&amp; ex):
<span class="lineNum">    1438 </span>            :             base_type(ex) {}
<span class="lineNum">    1439 </span>            : 
<span class="lineNum">    1440 </span>            :         ~BOOST_THREAD_FUTURE() {}
<span class="lineNum">    1441 </span>            : 
<span class="lineNum">    1442 </span>            :         BOOST_THREAD_FUTURE(BOOST_THREAD_RV_REF(BOOST_THREAD_FUTURE) other) BOOST_NOEXCEPT:
<span class="lineNum">    1443 </span>            :         base_type(boost::move(static_cast&lt;base_type&amp;&gt;(BOOST_THREAD_RV(other))))
<span class="lineNum">    1444 </span>            :         {
<span class="lineNum">    1445 </span>            :         }
<span class="lineNum">    1446 </span>            :         inline BOOST_THREAD_FUTURE(BOOST_THREAD_RV_REF(BOOST_THREAD_FUTURE&lt;BOOST_THREAD_FUTURE&lt;R&gt; &gt;) other); // EXTENSION
<span class="lineNum">    1447 </span>            : 
<span class="lineNum">    1448 </span>            :         explicit BOOST_THREAD_FUTURE(BOOST_THREAD_RV_REF(shared_future&lt;R&gt;) other) :
<span class="lineNum">    1449 </span>            :         base_type(boost::move(static_cast&lt;base_type&amp;&gt;(BOOST_THREAD_RV(other))))
<span class="lineNum">    1450 </span>            :         {}
<span class="lineNum">    1451 </span>            : 
<span class="lineNum">    1452 </span>            :         BOOST_THREAD_FUTURE&amp; operator=(BOOST_THREAD_RV_REF(BOOST_THREAD_FUTURE) other) BOOST_NOEXCEPT
<span class="lineNum">    1453 </span>            :         {
<span class="lineNum">    1454 </span>            :             this-&gt;base_type::operator=(boost::move(static_cast&lt;base_type&amp;&gt;(BOOST_THREAD_RV(other))));
<span class="lineNum">    1455 </span>            :             return *this;
<span class="lineNum">    1456 </span>            :         }
<span class="lineNum">    1457 </span>            : 
<span class="lineNum">    1458 </span>            :         shared_future&lt;R&gt; share()
<span class="lineNum">    1459 </span>            :         {
<span class="lineNum">    1460 </span>            :           return shared_future&lt;R&gt;(::boost::move(*this));
<span class="lineNum">    1461 </span>            :         }
<span class="lineNum">    1462 </span>            : 
<span class="lineNum">    1463 </span>            :         void swap(BOOST_THREAD_FUTURE&amp; other)
<span class="lineNum">    1464 </span>            :         {
<span class="lineNum">    1465 </span>            :             static_cast&lt;base_type*&gt;(this)-&gt;swap(other);
<span class="lineNum">    1466 </span>            :         }
<span class="lineNum">    1467 </span>            : 
<span class="lineNum">    1468 </span>            :         // todo this function must be private and friendship provided to the internal users.
<span class="lineNum">    1469 </span>            :         void set_async()
<span class="lineNum">    1470 </span>            :         {
<span class="lineNum">    1471 </span>            :           this-&gt;future_-&gt;set_async();
<span class="lineNum">    1472 </span>            :         }
<span class="lineNum">    1473 </span>            :         // todo this function must be private and friendship provided to the internal users.
<span class="lineNum">    1474 </span>            :         void set_deferred()
<span class="lineNum">    1475 </span>            :         {
<span class="lineNum">    1476 </span>            :           this-&gt;future_-&gt;set_deferred();
<span class="lineNum">    1477 </span>            :         }
<span class="lineNum">    1478 </span>            :         bool run_if_is_deferred() {
<span class="lineNum">    1479 </span>            :           return this-&gt;future_-&gt;run_if_is_deferred();
<span class="lineNum">    1480 </span>            :         }
<span class="lineNum">    1481 </span>            :         bool run_if_is_deferred_or_ready() {
<span class="lineNum">    1482 </span>            :           return this-&gt;future_-&gt;run_if_is_deferred_or_ready();
<span class="lineNum">    1483 </span>            :         }
<span class="lineNum">    1484 </span>            :         // retrieving the value
<span class="lineNum">    1485 </span>            :         move_dest_type get()
<span class="lineNum">    1486 </span>            :         {
<span class="lineNum">    1487 </span>            :             if (this-&gt;future_ == 0)
<span class="lineNum">    1488 </span>            :             {
<span class="lineNum">    1489 </span>            :                 boost::throw_exception(future_uninitialized());
<span class="lineNum">    1490 </span>            :             }
<span class="lineNum">    1491 </span>            :             unique_lock&lt;boost::mutex&gt; lk(this-&gt;future_-&gt;mutex);
<span class="lineNum">    1492 </span>            :             if (! this-&gt;future_-&gt;valid(lk))
<span class="lineNum">    1493 </span>            :             {
<span class="lineNum">    1494 </span>            :                 boost::throw_exception(future_uninitialized());
<span class="lineNum">    1495 </span>            :             }
<span class="lineNum">    1496 </span>            : #ifdef BOOST_THREAD_PROVIDES_FUTURE_INVALID_AFTER_GET
<span class="lineNum">    1497 </span>            :             this-&gt;future_-&gt;invalidate(lk);
<span class="lineNum">    1498 </span>            : #endif
<span class="lineNum">    1499 </span>            :             return this-&gt;future_-&gt;get(lk);
<span class="lineNum">    1500 </span>            :         }
<span class="lineNum">    1501 </span>            : 
<span class="lineNum">    1502 </span>            :         template &lt;typename R2&gt;
<span class="lineNum">    1503 </span>            :         typename boost::disable_if&lt; is_void&lt;R2&gt;, move_dest_type&gt;::type
<span class="lineNum">    1504 </span>            :         get_or(BOOST_THREAD_RV_REF(R2) v)
<span class="lineNum">    1505 </span>            :         {
<span class="lineNum">    1506 </span>            : 
<span class="lineNum">    1507 </span>            :             if (this-&gt;future_ == 0)
<span class="lineNum">    1508 </span>            :             {
<span class="lineNum">    1509 </span>            :                 boost::throw_exception(future_uninitialized());
<span class="lineNum">    1510 </span>            :             }
<span class="lineNum">    1511 </span>            :             unique_lock&lt;boost::mutex&gt; lk(this-&gt;future_-&gt;mutex);
<span class="lineNum">    1512 </span>            :             if (! this-&gt;future_-&gt;valid(lk))
<span class="lineNum">    1513 </span>            :             {
<span class="lineNum">    1514 </span>            :                 boost::throw_exception(future_uninitialized());
<span class="lineNum">    1515 </span>            :             }
<span class="lineNum">    1516 </span>            :             this-&gt;future_-&gt;wait(lk, false);
<span class="lineNum">    1517 </span>            : #ifdef BOOST_THREAD_PROVIDES_FUTURE_INVALID_AFTER_GET
<span class="lineNum">    1518 </span>            :             this-&gt;future_-&gt;invalidate(lk);
<span class="lineNum">    1519 </span>            : #endif
<span class="lineNum">    1520 </span>            : 
<span class="lineNum">    1521 </span>            :             if (this-&gt;future_-&gt;has_value(lk)) {
<span class="lineNum">    1522 </span>            :               return this-&gt;future_-&gt;get(lk);
<span class="lineNum">    1523 </span>            :             }
<span class="lineNum">    1524 </span>            :             else {
<span class="lineNum">    1525 </span>            :               return boost::move(v);
<span class="lineNum">    1526 </span>            :             }
<span class="lineNum">    1527 </span>            :         }
<span class="lineNum">    1528 </span>            : 
<span class="lineNum">    1529 </span>            :         template &lt;typename R2&gt;
<span class="lineNum">    1530 </span>            :         typename boost::disable_if&lt; is_void&lt;R2&gt;, move_dest_type&gt;::type
<span class="lineNum">    1531 </span>            :         get_or(R2 const&amp; v)  // EXTENSION
<span class="lineNum">    1532 </span>            :         {
<span class="lineNum">    1533 </span>            :             if (this-&gt;future_ == 0)
<span class="lineNum">    1534 </span>            :             {
<span class="lineNum">    1535 </span>            :                 boost::throw_exception(future_uninitialized());
<span class="lineNum">    1536 </span>            :             }
<span class="lineNum">    1537 </span>            :             unique_lock&lt;boost::mutex&gt; lk(this-&gt;future_-&gt;mutex);
<span class="lineNum">    1538 </span>            :             if (! this-&gt;future_-&gt;valid(lk))
<span class="lineNum">    1539 </span>            :             {
<span class="lineNum">    1540 </span>            :                 boost::throw_exception(future_uninitialized());
<span class="lineNum">    1541 </span>            :             }
<span class="lineNum">    1542 </span>            :             this-&gt;future_-&gt;wait(lk, false);
<span class="lineNum">    1543 </span>            : #ifdef BOOST_THREAD_PROVIDES_FUTURE_INVALID_AFTER_GET
<span class="lineNum">    1544 </span>            :             this-&gt;future_-&gt;invalidate(lk);
<span class="lineNum">    1545 </span>            : #endif
<span class="lineNum">    1546 </span>            :             if (this-&gt;future_-&gt;has_value(lk)) {
<span class="lineNum">    1547 </span>            :               return this-&gt;future_-&gt;get(lk);
<span class="lineNum">    1548 </span>            :             }
<span class="lineNum">    1549 </span>            :             else {
<span class="lineNum">    1550 </span>            :               return v;
<span class="lineNum">    1551 </span>            :             }
<span class="lineNum">    1552 </span>            :         }
<span class="lineNum">    1553 </span>            : 
<span class="lineNum">    1554 </span>            : #if defined BOOST_THREAD_PROVIDES_FUTURE_CONTINUATION
<span class="lineNum">    1555 </span>            :         template&lt;typename F&gt;
<span class="lineNum">    1556 </span>            :         inline BOOST_THREAD_FUTURE&lt;typename boost::result_of&lt;F(BOOST_THREAD_FUTURE)&gt;::type&gt;
<span class="lineNum">    1557 </span>            :         then(BOOST_THREAD_FWD_REF(F) func);  // EXTENSION
<span class="lineNum">    1558 </span>            :         template&lt;typename F&gt;
<span class="lineNum">    1559 </span>            :         inline BOOST_THREAD_FUTURE&lt;typename boost::result_of&lt;F(BOOST_THREAD_FUTURE)&gt;::type&gt;
<span class="lineNum">    1560 </span>            :         then(launch policy, BOOST_THREAD_FWD_REF(F) func);  // EXTENSION
<span class="lineNum">    1561 </span>            :   #ifdef BOOST_THREAD_PROVIDES_EXECUTORS
<span class="lineNum">    1562 </span>            :         template&lt;typename Ex, typename F&gt;
<span class="lineNum">    1563 </span>            :         inline BOOST_THREAD_FUTURE&lt;typename boost::result_of&lt;F(BOOST_THREAD_FUTURE)&gt;::type&gt;
<span class="lineNum">    1564 </span>            :         then(Ex&amp; ex, BOOST_THREAD_FWD_REF(F) func);  // EXTENSION
<span class="lineNum">    1565 </span>            :   #endif
<span class="lineNum">    1566 </span>            : 
<span class="lineNum">    1567 </span>            :         template &lt;typename R2&gt;
<span class="lineNum">    1568 </span>            :         inline typename boost::disable_if&lt; is_void&lt;R2&gt;, BOOST_THREAD_FUTURE&lt;R&gt; &gt;::type
<span class="lineNum">    1569 </span>            :         fallback_to(BOOST_THREAD_RV_REF(R2) v);  // EXTENSION
<span class="lineNum">    1570 </span>            :         template &lt;typename R2&gt;
<span class="lineNum">    1571 </span>            :         inline typename boost::disable_if&lt; is_void&lt;R2&gt;, BOOST_THREAD_FUTURE&lt;R&gt; &gt;::type
<span class="lineNum">    1572 </span>            :         fallback_to(R2 const&amp; v);  // EXTENSION
<span class="lineNum">    1573 </span>            : 
<span class="lineNum">    1574 </span>            : #endif
<span class="lineNum">    1575 </span>            : 
<span class="lineNum">    1576 </span>            :     };
<span class="lineNum">    1577 </span>            : 
<span class="lineNum">    1578 </span>            :     BOOST_THREAD_DCL_MOVABLE_BEG(T) BOOST_THREAD_FUTURE&lt;T&gt; BOOST_THREAD_DCL_MOVABLE_END
<span class="lineNum">    1579 </span>            : 
<span class="lineNum">    1580 </span>            :         template &lt;typename R2&gt;
<span class="lineNum">    1581 </span>            :         class BOOST_THREAD_FUTURE&lt;BOOST_THREAD_FUTURE&lt;R2&gt; &gt; : public detail::basic_future&lt;BOOST_THREAD_FUTURE&lt;R2&gt; &gt;
<span class="lineNum">    1582 </span>            :         {
<span class="lineNum">    1583 </span>            :           typedef BOOST_THREAD_FUTURE&lt;R2&gt; R;
<span class="lineNum">    1584 </span>            : 
<span class="lineNum">    1585 </span>            :         private:
<span class="lineNum">    1586 </span>            :             typedef detail::basic_future&lt;R&gt; base_type;
<span class="lineNum">    1587 </span>            :             typedef typename base_type::future_ptr future_ptr;
<span class="lineNum">    1588 </span>            : 
<span class="lineNum">    1589 </span>            :             friend class shared_future&lt;R&gt;;
<span class="lineNum">    1590 </span>            :             friend class promise&lt;R&gt;;
<span class="lineNum">    1591 </span>            :     #if defined BOOST_THREAD_PROVIDES_FUTURE_CONTINUATION
<span class="lineNum">    1592 </span>            :             template &lt;typename, typename, typename&gt;
<span class="lineNum">    1593 </span>            :             friend struct detail::future_async_continuation_shared_state;
<span class="lineNum">    1594 </span>            :             template &lt;typename, typename, typename&gt;
<span class="lineNum">    1595 </span>            :             friend struct detail::future_deferred_continuation_shared_state;
<span class="lineNum">    1596 </span>            : 
<span class="lineNum">    1597 </span>            :             template &lt;class F, class Rp, class Fp&gt;
<span class="lineNum">    1598 </span>            :             friend BOOST_THREAD_FUTURE&lt;Rp&gt;
<span class="lineNum">    1599 </span>            :             detail::make_future_async_continuation_shared_state(boost::unique_lock&lt;boost::mutex&gt; &amp;lock, BOOST_THREAD_RV_REF(F) f, BOOST_THREAD_FWD_REF(Fp) c);
<span class="lineNum">    1600 </span>            : 
<span class="lineNum">    1601 </span>            :             template &lt;class F, class Rp, class Fp&gt;
<span class="lineNum">    1602 </span>            :             friend BOOST_THREAD_FUTURE&lt;Rp&gt;
<span class="lineNum">    1603 </span>            :             detail::make_future_deferred_continuation_shared_state(boost::unique_lock&lt;boost::mutex&gt; &amp;lock, BOOST_THREAD_RV_REF(F) f, BOOST_THREAD_FWD_REF(Fp) c);
<span class="lineNum">    1604 </span>            :     #endif
<span class="lineNum">    1605 </span>            : #if defined BOOST_THREAD_PROVIDES_FUTURE_UNWRAP
<span class="lineNum">    1606 </span>            :             template&lt;typename F, typename Rp&gt;
<span class="lineNum">    1607 </span>            :             friend struct detail::future_unwrap_shared_state;
<span class="lineNum">    1608 </span>            :         template &lt;class F, class Rp&gt;
<span class="lineNum">    1609 </span>            :         friend BOOST_THREAD_FUTURE&lt;Rp&gt;
<span class="lineNum">    1610 </span>            :         detail::make_future_unwrap_shared_state(boost::unique_lock&lt;boost::mutex&gt; &amp;lock, BOOST_THREAD_RV_REF(F) f);
<span class="lineNum">    1611 </span>            : #endif
<span class="lineNum">    1612 </span>            :     #if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK
<span class="lineNum">    1613 </span>            :             template &lt;class&gt; friend class packaged_task; // todo check if this works in windows
<span class="lineNum">    1614 </span>            :     #else
<span class="lineNum">    1615 </span>            :             friend class packaged_task&lt;R&gt;;
<span class="lineNum">    1616 </span>            :     #endif
<span class="lineNum">    1617 </span>            :             friend class detail::future_waiter;
<span class="lineNum">    1618 </span>            : 
<span class="lineNum">    1619 </span>            :             template &lt;class Rp, class Fp&gt;
<span class="lineNum">    1620 </span>            :             friend BOOST_THREAD_FUTURE&lt;Rp&gt;
<span class="lineNum">    1621 </span>            :             detail::make_future_async_shared_state(BOOST_THREAD_FWD_REF(Fp) f);
<span class="lineNum">    1622 </span>            : 
<span class="lineNum">    1623 </span>            :             template &lt;class Rp, class Fp&gt;
<span class="lineNum">    1624 </span>            :             friend BOOST_THREAD_FUTURE&lt;Rp&gt;
<span class="lineNum">    1625 </span>            :             detail::make_future_deferred_shared_state(BOOST_THREAD_FWD_REF(Fp) f);
<span class="lineNum">    1626 </span>            : 
<span class="lineNum">    1627 </span>            :             typedef typename base_type::move_dest_type move_dest_type;
<span class="lineNum">    1628 </span>            : 
<span class="lineNum">    1629 </span>            :             BOOST_THREAD_FUTURE(future_ptr a_future):
<span class="lineNum">    1630 </span>            :               base_type(a_future)
<span class="lineNum">    1631 </span>            :             {
<span class="lineNum">    1632 </span>            :             }
<span class="lineNum">    1633 </span>            : 
<span class="lineNum">    1634 </span>            :         public:
<span class="lineNum">    1635 </span>            :             BOOST_THREAD_MOVABLE_ONLY(BOOST_THREAD_FUTURE)
<span class="lineNum">    1636 </span>            :             typedef future_state::state state;
<span class="lineNum">    1637 </span>            :             typedef R value_type; // EXTENSION
<span class="lineNum">    1638 </span>            : 
<span class="lineNum">    1639 </span>            :             BOOST_CONSTEXPR BOOST_THREAD_FUTURE() {}
<span class="lineNum">    1640 </span>            :             //BOOST_CONSTEXPR
<span class="lineNum">    1641 </span>            :             BOOST_THREAD_FUTURE(exceptional_ptr const&amp; ex):
<span class="lineNum">    1642 </span>            :                 base_type(ex) {}
<span class="lineNum">    1643 </span>            : 
<span class="lineNum">    1644 </span>            :             ~BOOST_THREAD_FUTURE() {}
<span class="lineNum">    1645 </span>            : 
<span class="lineNum">    1646 </span>            :             BOOST_THREAD_FUTURE(BOOST_THREAD_RV_REF(BOOST_THREAD_FUTURE) other) BOOST_NOEXCEPT:
<span class="lineNum">    1647 </span>            :             base_type(boost::move(static_cast&lt;base_type&amp;&gt;(BOOST_THREAD_RV(other))))
<span class="lineNum">    1648 </span>            :             {
<span class="lineNum">    1649 </span>            :             }
<span class="lineNum">    1650 </span>            : 
<span class="lineNum">    1651 </span>            :             BOOST_THREAD_FUTURE&amp; operator=(BOOST_THREAD_RV_REF(BOOST_THREAD_FUTURE) other) BOOST_NOEXCEPT
<span class="lineNum">    1652 </span>            :             {
<span class="lineNum">    1653 </span>            :                 this-&gt;base_type::operator=(boost::move(static_cast&lt;base_type&amp;&gt;(BOOST_THREAD_RV(other))));
<span class="lineNum">    1654 </span>            :                 return *this;
<span class="lineNum">    1655 </span>            :             }
<span class="lineNum">    1656 </span>            : 
<span class="lineNum">    1657 </span>            :             shared_future&lt;R&gt; share()
<span class="lineNum">    1658 </span>            :             {
<span class="lineNum">    1659 </span>            :               return shared_future&lt;R&gt;(::boost::move(*this));
<span class="lineNum">    1660 </span>            :             }
<span class="lineNum">    1661 </span>            : 
<span class="lineNum">    1662 </span>            :             void swap(BOOST_THREAD_FUTURE&amp; other)
<span class="lineNum">    1663 </span>            :             {
<span class="lineNum">    1664 </span>            :                 static_cast&lt;base_type*&gt;(this)-&gt;swap(other);
<span class="lineNum">    1665 </span>            :             }
<span class="lineNum">    1666 </span>            : 
<span class="lineNum">    1667 </span>            :             // todo this function must be private and friendship provided to the internal users.
<span class="lineNum">    1668 </span>            :             void set_async()
<span class="lineNum">    1669 </span>            :             {
<span class="lineNum">    1670 </span>            :               this-&gt;future_-&gt;set_async();
<span class="lineNum">    1671 </span>            :             }
<span class="lineNum">    1672 </span>            :             // todo this function must be private and friendship provided to the internal users.
<span class="lineNum">    1673 </span>            :             void set_deferred()
<span class="lineNum">    1674 </span>            :             {
<span class="lineNum">    1675 </span>            :               this-&gt;future_-&gt;set_deferred();
<span class="lineNum">    1676 </span>            :             }
<span class="lineNum">    1677 </span>            :             bool run_if_is_deferred() {
<span class="lineNum">    1678 </span>            :               return this-&gt;future_-&gt;run_if_is_deferred();
<span class="lineNum">    1679 </span>            :             }
<span class="lineNum">    1680 </span>            :             bool run_if_is_deferred_or_ready() {
<span class="lineNum">    1681 </span>            :               return this-&gt;future_-&gt;run_if_is_deferred_or_ready();
<span class="lineNum">    1682 </span>            :             }
<span class="lineNum">    1683 </span>            :             // retrieving the value
<span class="lineNum">    1684 </span>            :             move_dest_type get()
<span class="lineNum">    1685 </span>            :             {
<span class="lineNum">    1686 </span>            :                 if (this-&gt;future_ == 0)
<span class="lineNum">    1687 </span>            :                 {
<span class="lineNum">    1688 </span>            :                     boost::throw_exception(future_uninitialized());
<span class="lineNum">    1689 </span>            :                 }
<span class="lineNum">    1690 </span>            :                 unique_lock&lt;boost::mutex&gt; lk(this-&gt;future_-&gt;mutex);
<span class="lineNum">    1691 </span>            :                 if (! this-&gt;future_-&gt;valid(lk))
<span class="lineNum">    1692 </span>            :                 {
<span class="lineNum">    1693 </span>            :                     boost::throw_exception(future_uninitialized());
<span class="lineNum">    1694 </span>            :                 }
<span class="lineNum">    1695 </span>            :     #ifdef BOOST_THREAD_PROVIDES_FUTURE_INVALID_AFTER_GET
<span class="lineNum">    1696 </span>            :                 this-&gt;future_-&gt;invalidate(lk);
<span class="lineNum">    1697 </span>            :     #endif
<span class="lineNum">    1698 </span>            :                 return this-&gt;future_-&gt;get(lk);
<span class="lineNum">    1699 </span>            :             }
<span class="lineNum">    1700 </span>            :             move_dest_type get_or(BOOST_THREAD_RV_REF(R) v) // EXTENSION
<span class="lineNum">    1701 </span>            :             {
<span class="lineNum">    1702 </span>            :                 if (this-&gt;future_ == 0)
<span class="lineNum">    1703 </span>            :                 {
<span class="lineNum">    1704 </span>            :                     boost::throw_exception(future_uninitialized());
<span class="lineNum">    1705 </span>            :                 }
<span class="lineNum">    1706 </span>            :                 unique_lock&lt;boost::mutex&gt; lk(this-&gt;future_-&gt;mutex);
<span class="lineNum">    1707 </span>            :                 if (! this-&gt;future_-&gt;valid(lk))
<span class="lineNum">    1708 </span>            :                 {
<span class="lineNum">    1709 </span>            :                     boost::throw_exception(future_uninitialized());
<span class="lineNum">    1710 </span>            :                 }
<span class="lineNum">    1711 </span>            :                 this-&gt;future_-&gt;wait(lk, false);
<span class="lineNum">    1712 </span>            :     #ifdef BOOST_THREAD_PROVIDES_FUTURE_INVALID_AFTER_GET
<span class="lineNum">    1713 </span>            :                 this-&gt;future_-&gt;invalidate(lk);
<span class="lineNum">    1714 </span>            :     #endif
<span class="lineNum">    1715 </span>            :                 if (this-&gt;future_-&gt;has_value(lk)) return this-&gt;future_-&gt;get(lk);
<span class="lineNum">    1716 </span>            :                 else return boost::move(v);
<span class="lineNum">    1717 </span>            :             }
<span class="lineNum">    1718 </span>            : 
<span class="lineNum">    1719 </span>            :             move_dest_type get_or(R const&amp; v) // EXTENSION
<span class="lineNum">    1720 </span>            :             {
<span class="lineNum">    1721 </span>            :                 if (this-&gt;future_ == 0)
<span class="lineNum">    1722 </span>            :                 {
<span class="lineNum">    1723 </span>            :                     boost::throw_exception(future_uninitialized());
<span class="lineNum">    1724 </span>            :                 }
<span class="lineNum">    1725 </span>            :                 unique_lock&lt;boost::mutex&gt; lk(this-&gt;future_-&gt;mutex);
<span class="lineNum">    1726 </span>            :                 if (! this-&gt;future_-&gt;valid(lk))
<span class="lineNum">    1727 </span>            :                 {
<span class="lineNum">    1728 </span>            :                     boost::throw_exception(future_uninitialized());
<span class="lineNum">    1729 </span>            :                 }
<span class="lineNum">    1730 </span>            :                 this-&gt;future_-&gt;wait(lk, false);
<span class="lineNum">    1731 </span>            :     #ifdef BOOST_THREAD_PROVIDES_FUTURE_INVALID_AFTER_GET
<span class="lineNum">    1732 </span>            :                 this-&gt;future_-&gt;invalidate(lk);
<span class="lineNum">    1733 </span>            :     #endif
<span class="lineNum">    1734 </span>            :                 if (this-&gt;future_-&gt;has_value(lk)) return this-&gt;future_-&gt;get(lk);
<span class="lineNum">    1735 </span>            :                 else return v;
<span class="lineNum">    1736 </span>            :             }
<span class="lineNum">    1737 </span>            : 
<span class="lineNum">    1738 </span>            : 
<span class="lineNum">    1739 </span>            :     #if defined BOOST_THREAD_PROVIDES_FUTURE_CONTINUATION
<span class="lineNum">    1740 </span>            :             template&lt;typename F&gt;
<span class="lineNum">    1741 </span>            :             inline BOOST_THREAD_FUTURE&lt;typename boost::result_of&lt;F(BOOST_THREAD_FUTURE)&gt;::type&gt;
<span class="lineNum">    1742 </span>            :             then(BOOST_THREAD_FWD_REF(F) func); // EXTENSION
<span class="lineNum">    1743 </span>            :             template&lt;typename F&gt;
<span class="lineNum">    1744 </span>            :             inline BOOST_THREAD_FUTURE&lt;typename boost::result_of&lt;F(BOOST_THREAD_FUTURE)&gt;::type&gt;
<span class="lineNum">    1745 </span>            :             then(launch policy, BOOST_THREAD_FWD_REF(F) func); // EXTENSION
<span class="lineNum">    1746 </span>            :       #ifdef BOOST_THREAD_PROVIDES_EXECUTORS
<span class="lineNum">    1747 </span>            :             template&lt;typename Ex, typename F&gt;
<span class="lineNum">    1748 </span>            :             inline BOOST_THREAD_FUTURE&lt;typename boost::result_of&lt;F(BOOST_THREAD_FUTURE)&gt;::type&gt;
<span class="lineNum">    1749 </span>            :             then(Ex &amp;ex, BOOST_THREAD_FWD_REF(F) func); // EXTENSION
<span class="lineNum">    1750 </span>            :       #endif
<span class="lineNum">    1751 </span>            :     #endif
<span class="lineNum">    1752 </span>            : 
<span class="lineNum">    1753 </span>            :     #if defined BOOST_THREAD_PROVIDES_FUTURE_UNWRAP
<span class="lineNum">    1754 </span>            :             inline
<span class="lineNum">    1755 </span>            :             BOOST_THREAD_FUTURE&lt;R2&gt;
<span class="lineNum">    1756 </span>            :             unwrap(); // EXTENSION
<span class="lineNum">    1757 </span>            :     #endif
<span class="lineNum">    1758 </span>            : 
<span class="lineNum">    1759 </span>            :   };
<span class="lineNum">    1760 </span>            : 
<span class="lineNum">    1761 </span>            :     template &lt;typename R&gt;
<span class="lineNum">    1762 </span>            :     class shared_future : public detail::basic_future&lt;R&gt;
<span class="lineNum">    1763 </span>            :     {
<span class="lineNum">    1764 </span>            :         typedef detail::basic_future&lt;R&gt; base_type;
<span class="lineNum">    1765 </span>            :         typedef typename base_type::future_ptr future_ptr;
<span class="lineNum">    1766 </span>            : 
<span class="lineNum">    1767 </span>            :         friend class detail::future_waiter;
<span class="lineNum">    1768 </span>            :         friend class promise&lt;R&gt;;
<span class="lineNum">    1769 </span>            : 
<span class="lineNum">    1770 </span>            : #if defined BOOST_THREAD_PROVIDES_FUTURE_CONTINUATION
<span class="lineNum">    1771 </span>            :         template &lt;typename, typename, typename&gt;
<span class="lineNum">    1772 </span>            :         friend struct detail::future_async_continuation_shared_state;
<span class="lineNum">    1773 </span>            :         template &lt;typename, typename, typename&gt;
<span class="lineNum">    1774 </span>            :         friend struct detail::future_deferred_continuation_shared_state;
<span class="lineNum">    1775 </span>            : 
<span class="lineNum">    1776 </span>            :         template &lt;class F, class Rp, class Fp&gt;
<span class="lineNum">    1777 </span>            :         friend BOOST_THREAD_FUTURE&lt;Rp&gt;
<span class="lineNum">    1778 </span>            :         detail::make_future_async_continuation_shared_state(boost::unique_lock&lt;boost::mutex&gt; &amp;lock, BOOST_THREAD_RV_REF(F) f, BOOST_THREAD_FWD_REF(Fp) c);
<span class="lineNum">    1779 </span>            : 
<span class="lineNum">    1780 </span>            :         template &lt;class F, class Rp, class Fp&gt;
<span class="lineNum">    1781 </span>            :         friend BOOST_THREAD_FUTURE&lt;Rp&gt;
<span class="lineNum">    1782 </span>            :         detail::make_future_deferred_continuation_shared_state(boost::unique_lock&lt;boost::mutex&gt; &amp;lock, BOOST_THREAD_RV_REF(F) f, BOOST_THREAD_FWD_REF(Fp) c);
<span class="lineNum">    1783 </span>            : #endif
<span class="lineNum">    1784 </span>            : #if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK
<span class="lineNum">    1785 </span>            :         template &lt;class&gt; friend class packaged_task;// todo check if this works in windows
<span class="lineNum">    1786 </span>            : #else
<span class="lineNum">    1787 </span>            :         friend class packaged_task&lt;R&gt;;
<span class="lineNum">    1788 </span>            : #endif
<span class="lineNum">    1789 </span>            :         shared_future(future_ptr a_future):
<span class="lineNum">    1790 </span>            :           base_type(a_future)
<span class="lineNum">    1791 </span>            :         {}
<span class="lineNum">    1792 </span>            : 
<span class="lineNum">    1793 </span>            :     public:
<span class="lineNum">    1794 </span>            :         BOOST_THREAD_COPYABLE_AND_MOVABLE(shared_future)
<span class="lineNum">    1795 </span>            :         typedef R value_type; // EXTENSION
<span class="lineNum">    1796 </span>            : 
<span class="lineNum">    1797 </span>            :         shared_future(shared_future const&amp; other):
<span class="lineNum">    1798 </span>            :         base_type(other.future_)
<span class="lineNum">    1799 </span>            :         {}
<span class="lineNum">    1800 </span>            : 
<span class="lineNum">    1801 </span>            :         typedef future_state::state state;
<span class="lineNum">    1802 </span>            : 
<span class="lineNum">    1803 </span>            :         BOOST_CONSTEXPR shared_future()
<span class="lineNum">    1804 </span>            :         {}
<span class="lineNum">    1805 </span>            :         //BOOST_CONSTEXPR
<span class="lineNum">    1806 </span>            :         shared_future(exceptional_ptr const&amp; ex):
<span class="lineNum">    1807 </span>            :             base_type(ex) {}
<span class="lineNum">    1808 </span>            :         ~shared_future()
<span class="lineNum">    1809 </span>            :         {}
<span class="lineNum">    1810 </span>            : 
<span class="lineNum">    1811 </span>            :         shared_future&amp; operator=(BOOST_THREAD_COPY_ASSIGN_REF(shared_future) other)
<span class="lineNum">    1812 </span>            :         {
<span class="lineNum">    1813 </span>            :             if (other.future_) {
<span class="lineNum">    1814 </span>            :                 other.future_-&gt;inc();
<span class="lineNum">    1815 </span>            :             }
<span class="lineNum">    1816 </span>            :             if (this-&gt;future_) {
<span class="lineNum">    1817 </span>            :                 this-&gt;future_-&gt;dec();
<span class="lineNum">    1818 </span>            :             }
<span class="lineNum">    1819 </span>            :             this-&gt;future_ = other.future_;
<span class="lineNum">    1820 </span>            :             return *this;
<span class="lineNum">    1821 </span>            :         }
<span class="lineNum">    1822 </span>            : 
<span class="lineNum">    1823 </span>            :         shared_future(BOOST_THREAD_RV_REF(shared_future) other) BOOST_NOEXCEPT :
<span class="lineNum">    1824 </span>            :         base_type(boost::move(static_cast&lt;base_type&amp;&gt;(BOOST_THREAD_RV(other))))
<span class="lineNum">    1825 </span>            :         {
<span class="lineNum">    1826 </span>            :         }
<span class="lineNum">    1827 </span>            :         shared_future(BOOST_THREAD_RV_REF( BOOST_THREAD_FUTURE&lt;R&gt; ) other) BOOST_NOEXCEPT :
<span class="lineNum">    1828 </span>            :         base_type(boost::move(static_cast&lt;base_type&amp;&gt;(BOOST_THREAD_RV(other))))
<span class="lineNum">    1829 </span>            :         {
<span class="lineNum">    1830 </span>            :         }
<span class="lineNum">    1831 </span>            : 
<span class="lineNum">    1832 </span>            :         shared_future&amp; operator=(BOOST_THREAD_RV_REF(shared_future) other) BOOST_NOEXCEPT
<span class="lineNum">    1833 </span>            :         {
<span class="lineNum">    1834 </span>            :             base_type::operator=(boost::move(static_cast&lt;base_type&amp;&gt;(BOOST_THREAD_RV(other))));
<span class="lineNum">    1835 </span>            :             return *this;
<span class="lineNum">    1836 </span>            :         }
<span class="lineNum">    1837 </span>            :         shared_future&amp; operator=(BOOST_THREAD_RV_REF( BOOST_THREAD_FUTURE&lt;R&gt; ) other) BOOST_NOEXCEPT
<span class="lineNum">    1838 </span>            :         {
<span class="lineNum">    1839 </span>            :             base_type::operator=(boost::move(static_cast&lt;base_type&amp;&gt;(BOOST_THREAD_RV(other))));
<span class="lineNum">    1840 </span>            :             return *this;
<span class="lineNum">    1841 </span>            :         }
<span class="lineNum">    1842 </span>            : 
<span class="lineNum">    1843 </span>            :         void swap(shared_future&amp; other) BOOST_NOEXCEPT
<span class="lineNum">    1844 </span>            :         {
<span class="lineNum">    1845 </span>            :             static_cast&lt;base_type*&gt;(this)-&gt;swap(other);
<span class="lineNum">    1846 </span>            :         }
<span class="lineNum">    1847 </span>            :         bool run_if_is_deferred() {
<span class="lineNum">    1848 </span>            :           return this-&gt;future_-&gt;run_if_is_deferred();
<span class="lineNum">    1849 </span>            :         }
<span class="lineNum">    1850 </span>            :         bool run_if_is_deferred_or_ready() {
<span class="lineNum">    1851 </span>            :           return this-&gt;future_-&gt;run_if_is_deferred_or_ready();
<span class="lineNum">    1852 </span>            :         }
<span class="lineNum">    1853 </span>            :         // retrieving the value
<span class="lineNum">    1854 </span>            :         typename detail::shared_state&lt;R&gt;::shared_future_get_result_type get() const
<span class="lineNum">    1855 </span>            :         {
<span class="lineNum">    1856 </span>            :             if(!this-&gt;future_)
<span class="lineNum">    1857 </span>            :             {
<span class="lineNum">    1858 </span>            :                 boost::throw_exception(future_uninitialized());
<span class="lineNum">    1859 </span>            :             }
<span class="lineNum">    1860 </span>            :             return this-&gt;future_-&gt;get_sh();
<span class="lineNum">    1861 </span>            :         }
<span class="lineNum">    1862 </span>            : 
<span class="lineNum">    1863 </span>            :         template &lt;typename R2&gt;
<span class="lineNum">    1864 </span>            :         typename boost::disable_if&lt; is_void&lt;R2&gt;, typename detail::shared_state&lt;R&gt;::shared_future_get_result_type&gt;::type
<span class="lineNum">    1865 </span>            :         get_or(BOOST_THREAD_RV_REF(R2) v)  const // EXTENSION
<span class="lineNum">    1866 </span>            :         {
<span class="lineNum">    1867 </span>            :             if(!this-&gt;future_)
<span class="lineNum">    1868 </span>            :             {
<span class="lineNum">    1869 </span>            :                 boost::throw_exception(future_uninitialized());
<span class="lineNum">    1870 </span>            :             }
<span class="lineNum">    1871 </span>            :             this-&gt;future_-&gt;wait();
<span class="lineNum">    1872 </span>            :             if (this-&gt;future_-&gt;has_value()) return this-&gt;future_-&gt;get_sh();
<span class="lineNum">    1873 </span>            :             else return boost::move(v);
<span class="lineNum">    1874 </span>            :         }
<span class="lineNum">    1875 </span>            : 
<span class="lineNum">    1876 </span>            : #if defined BOOST_THREAD_PROVIDES_FUTURE_CONTINUATION
<span class="lineNum">    1877 </span>            :         template&lt;typename F&gt;
<span class="lineNum">    1878 </span>            :         inline BOOST_THREAD_FUTURE&lt;typename boost::result_of&lt;F(shared_future)&gt;::type&gt;
<span class="lineNum">    1879 </span>            :         then(BOOST_THREAD_FWD_REF(F) func) const; // EXTENSION
<span class="lineNum">    1880 </span>            :         template&lt;typename F&gt;
<span class="lineNum">    1881 </span>            :         inline BOOST_THREAD_FUTURE&lt;typename boost::result_of&lt;F(shared_future)&gt;::type&gt;
<span class="lineNum">    1882 </span>            :         then(launch policy, BOOST_THREAD_FWD_REF(F) func) const; // EXTENSION
<span class="lineNum">    1883 </span>            :   #ifdef BOOST_THREAD_PROVIDES_EXECUTORS
<span class="lineNum">    1884 </span>            :         template&lt;typename Ex, typename F&gt;
<span class="lineNum">    1885 </span>            :         inline BOOST_THREAD_FUTURE&lt;typename boost::result_of&lt;F(shared_future)&gt;::type&gt;
<span class="lineNum">    1886 </span>            :         then(Ex&amp; ex, BOOST_THREAD_FWD_REF(F) func) const; // EXTENSION
<span class="lineNum">    1887 </span>            :   #endif
<span class="lineNum">    1888 </span>            : #endif
<span class="lineNum">    1889 </span>            : 
<span class="lineNum">    1890 </span>            :     };
<span class="lineNum">    1891 </span>            : 
<span class="lineNum">    1892 </span>            :     BOOST_THREAD_DCL_MOVABLE_BEG(T) shared_future&lt;T&gt; BOOST_THREAD_DCL_MOVABLE_END
<span class="lineNum">    1893 </span>            : 
<span class="lineNum">    1894 </span>            :     template &lt;typename R&gt;
<span class="lineNum">    1895 </span>            :     class promise
<span class="lineNum">    1896 </span>            :     {
<span class="lineNum">    1897 </span>            :         typedef boost::shared_ptr&lt;detail::shared_state&lt;R&gt; &gt; future_ptr;
<span class="lineNum">    1898 </span>            : 
<span class="lineNum">    1899 </span>            :         typedef typename detail::shared_state&lt;R&gt;::source_reference_type source_reference_type;
<span class="lineNum">    1900 </span>            :         typedef typename detail::shared_state&lt;R&gt;::rvalue_source_type rvalue_source_type;
<span class="lineNum">    1901 </span>            :         typedef typename detail::shared_state&lt;R&gt;::move_dest_type move_dest_type;
<span class="lineNum">    1902 </span>            :         typedef typename detail::shared_state&lt;R&gt;::shared_future_get_result_type shared_future_get_result_type;
<span class="lineNum">    1903 </span>            : 
<span class="lineNum">    1904 </span>            :         future_ptr future_;
<span class="lineNum">    1905 </span>            :         bool future_obtained;
<span class="lineNum">    1906 </span>            : 
<span class="lineNum">    1907 </span>            :         void lazy_init()
<span class="lineNum">    1908 </span>            :         {
<span class="lineNum">    1909 </span>            : #if defined BOOST_THREAD_PROVIDES_PROMISE_LAZY
<span class="lineNum">    1910 </span>            : #include &lt;boost/detail/atomic_undef_macros.hpp&gt;
<span class="lineNum">    1911 </span>            :           if(!atomic_load(&amp;future_))
<span class="lineNum">    1912 </span>            :             {
<span class="lineNum">    1913 </span>            :                 future_ptr blank;
<span class="lineNum">    1914 </span>            :                 atomic_compare_exchange(&amp;future_,&amp;blank,future_ptr(new detail::shared_state&lt;R&gt;));
<span class="lineNum">    1915 </span>            :             }
<span class="lineNum">    1916 </span>            : #include &lt;boost/detail/atomic_redef_macros.hpp&gt;
<span class="lineNum">    1917 </span>            : #endif
<span class="lineNum">    1918 </span>            :         }
<span class="lineNum">    1919 </span>            : 
<span class="lineNum">    1920 </span>            :     public:
<span class="lineNum">    1921 </span>            :         BOOST_THREAD_MOVABLE_ONLY(promise)
<span class="lineNum">    1922 </span>            : #if defined BOOST_THREAD_PROVIDES_FUTURE_CTOR_ALLOCATORS
<span class="lineNum">    1923 </span>            :         template &lt;class Allocator&gt;
<span class="lineNum">    1924 </span>            :         promise(boost::allocator_arg_t, Allocator a)
<span class="lineNum">    1925 </span>            :         {
<span class="lineNum">    1926 </span>            :           typedef typename Allocator::template rebind&lt;detail::shared_state&lt;R&gt; &gt;::other A2;
<span class="lineNum">    1927 </span>            :           A2 a2(a);
<span class="lineNum">    1928 </span>            :           typedef thread_detail::allocator_destructor&lt;A2&gt; D;
<span class="lineNum">    1929 </span>            : 
<span class="lineNum">    1930 </span>            :           future_ = future_ptr(::new(a2.allocate(1)) detail::shared_state&lt;R&gt;(), D(a2, 1) );
<span class="lineNum">    1931 </span>            :           future_obtained = false;
<span class="lineNum">    1932 </span>            :         }
<span class="lineNum">    1933 </span>            : #endif
<span class="lineNum">    1934 </span>            :         promise():
<span class="lineNum">    1935 </span>            : #if defined BOOST_THREAD_PROVIDES_PROMISE_LAZY
<span class="lineNum">    1936 </span>            :             future_(),
<span class="lineNum">    1937 </span>            : #else
<span class="lineNum">    1938 </span>            :             future_(new detail::shared_state&lt;R&gt;()),
<span class="lineNum">    1939 </span>            : #endif
<span class="lineNum">    1940 </span>            :             future_obtained(false)
<span class="lineNum">    1941 </span>            :         {}
<span class="lineNum">    1942 </span>            : 
<span class="lineNum">    1943 </span>            :         ~promise()
<span class="lineNum">    1944 </span>            :         {
<span class="lineNum">    1945 </span>            :             if(future_)
<span class="lineNum">    1946 </span>            :             {
<span class="lineNum">    1947 </span>            :                 boost::unique_lock&lt;boost::mutex&gt; lock(future_-&gt;mutex);
<span class="lineNum">    1948 </span>            : 
<span class="lineNum">    1949 </span>            :                 if(!future_-&gt;done &amp;&amp; !future_-&gt;is_constructed)
<span class="lineNum">    1950 </span>            :                 {
<span class="lineNum">    1951 </span>            :                     future_-&gt;mark_exceptional_finish_internal(boost::copy_exception(broken_promise()), lock);
<span class="lineNum">    1952 </span>            :                 }
<span class="lineNum">    1953 </span>            :             }
<span class="lineNum">    1954 </span>            :         }
<span class="lineNum">    1955 </span>            : 
<span class="lineNum">    1956 </span>            :         // Assignment
<span class="lineNum">    1957 </span>            :         promise(BOOST_THREAD_RV_REF(promise) rhs) BOOST_NOEXCEPT :
<span class="lineNum">    1958 </span>            :             future_(BOOST_THREAD_RV(rhs).future_),future_obtained(BOOST_THREAD_RV(rhs).future_obtained)
<span class="lineNum">    1959 </span>            :         {
<span class="lineNum">    1960 </span>            :             BOOST_THREAD_RV(rhs).future_.reset();
<span class="lineNum">    1961 </span>            :             BOOST_THREAD_RV(rhs).future_obtained=false;
<span class="lineNum">    1962 </span>            :         }
<span class="lineNum">    1963 </span>            :         promise &amp; operator=(BOOST_THREAD_RV_REF(promise) rhs) BOOST_NOEXCEPT
<span class="lineNum">    1964 </span>            :         {
<span class="lineNum">    1965 </span>            :             future_=BOOST_THREAD_RV(rhs).future_;
<span class="lineNum">    1966 </span>            :             future_obtained=BOOST_THREAD_RV(rhs).future_obtained;
<span class="lineNum">    1967 </span>            :             BOOST_THREAD_RV(rhs).future_.reset();
<span class="lineNum">    1968 </span>            :             BOOST_THREAD_RV(rhs).future_obtained=false;
<span class="lineNum">    1969 </span>            :             return *this;
<span class="lineNum">    1970 </span>            :         }
<span class="lineNum">    1971 </span>            : 
<span class="lineNum">    1972 </span>            :         void swap(promise&amp; other)
<span class="lineNum">    1973 </span>            :         {
<span class="lineNum">    1974 </span>            :             future_.swap(other.future_);
<span class="lineNum">    1975 </span>            :             std::swap(future_obtained,other.future_obtained);
<span class="lineNum">    1976 </span>            :         }
<span class="lineNum">    1977 </span>            : 
<span class="lineNum">    1978 </span>            :         // Result retrieval
<span class="lineNum">    1979 </span>            :         BOOST_THREAD_FUTURE&lt;R&gt; get_future()
<span class="lineNum">    1980 </span>            :         {
<span class="lineNum">    1981 </span>            :             lazy_init();
<span class="lineNum">    1982 </span>            :             if (future_.get()==0)
<span class="lineNum">    1983 </span>            :             {
<span class="lineNum">    1984 </span>            :                 boost::throw_exception(promise_moved());
<span class="lineNum">    1985 </span>            :             }
<span class="lineNum">    1986 </span>            :             if (future_obtained)
<span class="lineNum">    1987 </span>            :             {
<span class="lineNum">    1988 </span>            :                 boost::throw_exception(future_already_retrieved());
<span class="lineNum">    1989 </span>            :             }
<span class="lineNum">    1990 </span>            :             future_obtained=true;
<span class="lineNum">    1991 </span>            :             return BOOST_THREAD_FUTURE&lt;R&gt;(future_);
<span class="lineNum">    1992 </span>            :         }
<span class="lineNum">    1993 </span>            : 
<span class="lineNum">    1994 </span>            : #if defined  BOOST_NO_CXX11_RVALUE_REFERENCES
<span class="lineNum">    1995 </span>            :         template &lt;class TR&gt;
<span class="lineNum">    1996 </span>            :         typename boost::enable_if_c&lt;is_copy_constructible&lt;TR&gt;::value &amp;&amp; is_same&lt;R, TR&gt;::value, void&gt;::type set_value(TR const &amp;  r)
<span class="lineNum">    1997 </span>            :         {
<span class="lineNum">    1998 </span>            :             lazy_init();
<span class="lineNum">    1999 </span>            :             boost::unique_lock&lt;boost::mutex&gt; lock(future_-&gt;mutex);
<span class="lineNum">    2000 </span>            :             if(future_-&gt;done)
<span class="lineNum">    2001 </span>            :             {
<span class="lineNum">    2002 </span>            :                 boost::throw_exception(promise_already_satisfied());
<span class="lineNum">    2003 </span>            :             }
<span class="lineNum">    2004 </span>            :             future_-&gt;mark_finished_with_result_internal(r, lock);
<span class="lineNum">    2005 </span>            :         }
<span class="lineNum">    2006 </span>            : #else
<span class="lineNum">    2007 </span>            :         void set_value(source_reference_type r)
<span class="lineNum">    2008 </span>            :         {
<span class="lineNum">    2009 </span>            :             lazy_init();
<span class="lineNum">    2010 </span>            :             boost::unique_lock&lt;boost::mutex&gt; lock(future_-&gt;mutex);
<span class="lineNum">    2011 </span>            :             if(future_-&gt;done)
<span class="lineNum">    2012 </span>            :             {
<span class="lineNum">    2013 </span>            :                 boost::throw_exception(promise_already_satisfied());
<span class="lineNum">    2014 </span>            :             }
<span class="lineNum">    2015 </span>            :             future_-&gt;mark_finished_with_result_internal(r, lock);
<span class="lineNum">    2016 </span>            :         }
<span class="lineNum">    2017 </span>            : #endif
<span class="lineNum">    2018 </span>            : 
<span class="lineNum">    2019 </span>            :         void set_value(rvalue_source_type r)
<span class="lineNum">    2020 </span>            :         {
<span class="lineNum">    2021 </span>            :             lazy_init();
<span class="lineNum">    2022 </span>            :             boost::unique_lock&lt;boost::mutex&gt; lock(future_-&gt;mutex);
<span class="lineNum">    2023 </span>            :             if(future_-&gt;done)
<span class="lineNum">    2024 </span>            :             {
<span class="lineNum">    2025 </span>            :                 boost::throw_exception(promise_already_satisfied());
<span class="lineNum">    2026 </span>            :             }
<span class="lineNum">    2027 </span>            : #if ! defined  BOOST_NO_CXX11_RVALUE_REFERENCES
<span class="lineNum">    2028 </span>            :             future_-&gt;mark_finished_with_result_internal(boost::move(r), lock);
<span class="lineNum">    2029 </span>            : #else
<span class="lineNum">    2030 </span>            :             future_-&gt;mark_finished_with_result_internal(static_cast&lt;rvalue_source_type&gt;(r), lock);
<span class="lineNum">    2031 </span>            : #endif
<span class="lineNum">    2032 </span>            :         }
<span class="lineNum">    2033 </span>            : 
<span class="lineNum">    2034 </span>            : #if ! defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
<span class="lineNum">    2035 </span>            :         template &lt;class ...Args&gt;
<span class="lineNum">    2036 </span>            :         void emplace(BOOST_THREAD_FWD_REF(Args) ...args)
<span class="lineNum">    2037 </span>            :         {
<span class="lineNum">    2038 </span>            :             lazy_init();
<span class="lineNum">    2039 </span>            :             boost::unique_lock&lt;boost::mutex&gt; lock(future_-&gt;mutex);
<span class="lineNum">    2040 </span>            :             if(future_-&gt;done)
<span class="lineNum">    2041 </span>            :             {
<span class="lineNum">    2042 </span>            :                 boost::throw_exception(promise_already_satisfied());
<span class="lineNum">    2043 </span>            :             }
<span class="lineNum">    2044 </span>            :             future_-&gt;mark_finished_with_result_internal(lock, boost::forward&lt;Args&gt;(args)...);
<span class="lineNum">    2045 </span>            :         }
<span class="lineNum">    2046 </span>            : 
<span class="lineNum">    2047 </span>            : #endif
<span class="lineNum">    2048 </span>            : 
<span class="lineNum">    2049 </span>            :         void set_exception(boost::exception_ptr p)
<span class="lineNum">    2050 </span>            :         {
<span class="lineNum">    2051 </span>            :             lazy_init();
<span class="lineNum">    2052 </span>            :             boost::unique_lock&lt;boost::mutex&gt; lock(future_-&gt;mutex);
<span class="lineNum">    2053 </span>            :             if(future_-&gt;done)
<span class="lineNum">    2054 </span>            :             {
<span class="lineNum">    2055 </span>            :                 boost::throw_exception(promise_already_satisfied());
<span class="lineNum">    2056 </span>            :             }
<span class="lineNum">    2057 </span>            :             future_-&gt;mark_exceptional_finish_internal(p, lock);
<span class="lineNum">    2058 </span>            :         }
<span class="lineNum">    2059 </span>            :         template &lt;typename E&gt;
<span class="lineNum">    2060 </span>            :         void set_exception(E ex)
<span class="lineNum">    2061 </span>            :         {
<span class="lineNum">    2062 </span>            :           set_exception(boost::copy_exception(ex));
<span class="lineNum">    2063 </span>            :         }
<span class="lineNum">    2064 </span>            :         // setting the result with deferred notification
<span class="lineNum">    2065 </span>            : #if defined  BOOST_NO_CXX11_RVALUE_REFERENCES
<span class="lineNum">    2066 </span>            :         template &lt;class TR&gt;
<span class="lineNum">    2067 </span>            :         typename boost::enable_if_c&lt;is_copy_constructible&lt;TR&gt;::value &amp;&amp; is_same&lt;R, TR&gt;::value, void&gt;::type set_value_at_thread_exit(TR const&amp; r)
<span class="lineNum">    2068 </span>            :         {
<span class="lineNum">    2069 </span>            :           if (future_.get()==0)
<span class="lineNum">    2070 </span>            :           {
<span class="lineNum">    2071 </span>            :               boost::throw_exception(promise_moved());
<span class="lineNum">    2072 </span>            :           }
<span class="lineNum">    2073 </span>            :           future_-&gt;set_value_at_thread_exit(r);
<span class="lineNum">    2074 </span>            :         }
<span class="lineNum">    2075 </span>            : #else
<span class="lineNum">    2076 </span>            :         void set_value_at_thread_exit(source_reference_type r)
<span class="lineNum">    2077 </span>            :         {
<span class="lineNum">    2078 </span>            :           if (future_.get()==0)
<span class="lineNum">    2079 </span>            :           {
<span class="lineNum">    2080 </span>            :               boost::throw_exception(promise_moved());
<span class="lineNum">    2081 </span>            :           }
<span class="lineNum">    2082 </span>            :           future_-&gt;set_value_at_thread_exit(r);
<span class="lineNum">    2083 </span>            :         }
<span class="lineNum">    2084 </span>            : #endif
<span class="lineNum">    2085 </span>            :         void set_value_at_thread_exit(BOOST_THREAD_RV_REF(R) r)
<span class="lineNum">    2086 </span>            :         {
<span class="lineNum">    2087 </span>            :           if (future_.get()==0)
<span class="lineNum">    2088 </span>            :           {
<span class="lineNum">    2089 </span>            :               boost::throw_exception(promise_moved());
<span class="lineNum">    2090 </span>            :           }
<span class="lineNum">    2091 </span>            :           future_-&gt;set_value_at_thread_exit(boost::move(r));
<span class="lineNum">    2092 </span>            :         }
<span class="lineNum">    2093 </span>            :         void set_exception_at_thread_exit(exception_ptr e)
<span class="lineNum">    2094 </span>            :         {
<span class="lineNum">    2095 </span>            :           if (future_.get()==0)
<span class="lineNum">    2096 </span>            :           {
<span class="lineNum">    2097 </span>            :               boost::throw_exception(promise_moved());
<span class="lineNum">    2098 </span>            :           }
<span class="lineNum">    2099 </span>            :           future_-&gt;set_exception_at_thread_exit(e);
<span class="lineNum">    2100 </span>            :         }
<span class="lineNum">    2101 </span>            :         template &lt;typename E&gt;
<span class="lineNum">    2102 </span>            :         void set_exception_at_thread_exit(E ex)
<span class="lineNum">    2103 </span>            :         {
<span class="lineNum">    2104 </span>            :           set_exception_at_thread_exit(boost::copy_exception(ex));
<span class="lineNum">    2105 </span>            :         }
<span class="lineNum">    2106 </span>            : 
<span class="lineNum">    2107 </span>            :         template&lt;typename F&gt;
<span class="lineNum">    2108 </span>            :         void set_wait_callback(F f)
<span class="lineNum">    2109 </span>            :         {
<span class="lineNum">    2110 </span>            :             lazy_init();
<span class="lineNum">    2111 </span>            :             future_-&gt;set_wait_callback(f,this);
<span class="lineNum">    2112 </span>            :         }
<span class="lineNum">    2113 </span>            : 
<span class="lineNum">    2114 </span>            :     };
<span class="lineNum">    2115 </span>            : 
<span class="lineNum">    2116 </span>            :     template &lt;typename R&gt;
<span class="lineNum">    2117 </span>            :     class promise&lt;R&amp;&gt;
<span class="lineNum">    2118 </span>            :     {
<span class="lineNum">    2119 </span>            :         typedef boost::shared_ptr&lt;detail::shared_state&lt;R&amp;&gt; &gt; future_ptr;
<span class="lineNum">    2120 </span>            : 
<span class="lineNum">    2121 </span>            :         future_ptr future_;
<span class="lineNum">    2122 </span>            :         bool future_obtained;
<span class="lineNum">    2123 </span>            : 
<span class="lineNum">    2124 </span>            :         void lazy_init()
<span class="lineNum">    2125 </span>            :         {
<span class="lineNum">    2126 </span>            : #if defined BOOST_THREAD_PROVIDES_PROMISE_LAZY
<span class="lineNum">    2127 </span>            : #include &lt;boost/detail/atomic_undef_macros.hpp&gt;
<span class="lineNum">    2128 </span>            :             if(!atomic_load(&amp;future_))
<span class="lineNum">    2129 </span>            :             {
<span class="lineNum">    2130 </span>            :                 future_ptr blank;
<span class="lineNum">    2131 </span>            :                 atomic_compare_exchange(&amp;future_,&amp;blank,future_ptr(new detail::shared_state&lt;R&amp;&gt;));
<span class="lineNum">    2132 </span>            :             }
<span class="lineNum">    2133 </span>            : #include &lt;boost/detail/atomic_redef_macros.hpp&gt;
<span class="lineNum">    2134 </span>            : #endif
<span class="lineNum">    2135 </span>            :         }
<span class="lineNum">    2136 </span>            : 
<span class="lineNum">    2137 </span>            :     public:
<span class="lineNum">    2138 </span>            :         BOOST_THREAD_MOVABLE_ONLY(promise)
<span class="lineNum">    2139 </span>            : #if defined BOOST_THREAD_PROVIDES_FUTURE_CTOR_ALLOCATORS
<span class="lineNum">    2140 </span>            :         template &lt;class Allocator&gt;
<span class="lineNum">    2141 </span>            :         promise(boost::allocator_arg_t, Allocator a)
<span class="lineNum">    2142 </span>            :         {
<span class="lineNum">    2143 </span>            :           typedef typename Allocator::template rebind&lt;detail::shared_state&lt;R&amp;&gt; &gt;::other A2;
<span class="lineNum">    2144 </span>            :           A2 a2(a);
<span class="lineNum">    2145 </span>            :           typedef thread_detail::allocator_destructor&lt;A2&gt; D;
<span class="lineNum">    2146 </span>            : 
<span class="lineNum">    2147 </span>            :           future_ = future_ptr(::new(a2.allocate(1)) detail::shared_state&lt;R&amp;&gt;(), D(a2, 1) );
<span class="lineNum">    2148 </span>            :           future_obtained = false;
<span class="lineNum">    2149 </span>            :         }
<span class="lineNum">    2150 </span>            : #endif
<span class="lineNum">    2151 </span>            :         promise():
<span class="lineNum">    2152 </span>            : #if defined BOOST_THREAD_PROVIDES_PROMISE_LAZY
<span class="lineNum">    2153 </span>            :             future_(),
<span class="lineNum">    2154 </span>            : #else
<span class="lineNum">    2155 </span>            :             future_(new detail::shared_state&lt;R&amp;&gt;()),
<span class="lineNum">    2156 </span>            : #endif
<span class="lineNum">    2157 </span>            :             future_obtained(false)
<span class="lineNum">    2158 </span>            :         {}
<span class="lineNum">    2159 </span>            : 
<span class="lineNum">    2160 </span>            :         ~promise()
<span class="lineNum">    2161 </span>            :         {
<span class="lineNum">    2162 </span>            :             if(future_)
<span class="lineNum">    2163 </span>            :             {
<span class="lineNum">    2164 </span>            :                 boost::unique_lock&lt;boost::mutex&gt; lock(future_-&gt;mutex);
<span class="lineNum">    2165 </span>            : 
<span class="lineNum">    2166 </span>            :                 if(!future_-&gt;done &amp;&amp; !future_-&gt;is_constructed)
<span class="lineNum">    2167 </span>            :                 {
<span class="lineNum">    2168 </span>            :                     future_-&gt;mark_exceptional_finish_internal(boost::copy_exception(broken_promise()), lock);
<span class="lineNum">    2169 </span>            :                 }
<span class="lineNum">    2170 </span>            :             }
<span class="lineNum">    2171 </span>            :         }
<span class="lineNum">    2172 </span>            : 
<span class="lineNum">    2173 </span>            :         // Assignment
<span class="lineNum">    2174 </span>            :         promise(BOOST_THREAD_RV_REF(promise) rhs) BOOST_NOEXCEPT :
<span class="lineNum">    2175 </span>            :             future_(BOOST_THREAD_RV(rhs).future_),future_obtained(BOOST_THREAD_RV(rhs).future_obtained)
<span class="lineNum">    2176 </span>            :         {
<span class="lineNum">    2177 </span>            :             BOOST_THREAD_RV(rhs).future_.reset();
<span class="lineNum">    2178 </span>            :             BOOST_THREAD_RV(rhs).future_obtained=false;
<span class="lineNum">    2179 </span>            :         }
<span class="lineNum">    2180 </span>            :         promise &amp; operator=(BOOST_THREAD_RV_REF(promise) rhs) BOOST_NOEXCEPT
<span class="lineNum">    2181 </span>            :         {
<span class="lineNum">    2182 </span>            :             future_=BOOST_THREAD_RV(rhs).future_;
<span class="lineNum">    2183 </span>            :             future_obtained=BOOST_THREAD_RV(rhs).future_obtained;
<span class="lineNum">    2184 </span>            :             BOOST_THREAD_RV(rhs).future_.reset();
<span class="lineNum">    2185 </span>            :             BOOST_THREAD_RV(rhs).future_obtained=false;
<span class="lineNum">    2186 </span>            :             return *this;
<span class="lineNum">    2187 </span>            :         }
<span class="lineNum">    2188 </span>            : 
<span class="lineNum">    2189 </span>            :         void swap(promise&amp; other)
<span class="lineNum">    2190 </span>            :         {
<span class="lineNum">    2191 </span>            :             future_.swap(other.future_);
<span class="lineNum">    2192 </span>            :             std::swap(future_obtained,other.future_obtained);
<span class="lineNum">    2193 </span>            :         }
<span class="lineNum">    2194 </span>            : 
<span class="lineNum">    2195 </span>            :         // Result retrieval
<span class="lineNum">    2196 </span>            :         BOOST_THREAD_FUTURE&lt;R&amp;&gt; get_future()
<span class="lineNum">    2197 </span>            :         {
<span class="lineNum">    2198 </span>            :             lazy_init();
<span class="lineNum">    2199 </span>            :             if (future_.get()==0)
<span class="lineNum">    2200 </span>            :             {
<span class="lineNum">    2201 </span>            :                 boost::throw_exception(promise_moved());
<span class="lineNum">    2202 </span>            :             }
<span class="lineNum">    2203 </span>            :             if (future_obtained)
<span class="lineNum">    2204 </span>            :             {
<span class="lineNum">    2205 </span>            :                 boost::throw_exception(future_already_retrieved());
<span class="lineNum">    2206 </span>            :             }
<span class="lineNum">    2207 </span>            :             future_obtained=true;
<span class="lineNum">    2208 </span>            :             return BOOST_THREAD_FUTURE&lt;R&amp;&gt;(future_);
<span class="lineNum">    2209 </span>            :         }
<span class="lineNum">    2210 </span>            : 
<span class="lineNum">    2211 </span>            :         void set_value(R&amp; r)
<span class="lineNum">    2212 </span>            :         {
<span class="lineNum">    2213 </span>            :             lazy_init();
<span class="lineNum">    2214 </span>            :             boost::unique_lock&lt;boost::mutex&gt; lock(future_-&gt;mutex);
<span class="lineNum">    2215 </span>            :             if(future_-&gt;done)
<span class="lineNum">    2216 </span>            :             {
<span class="lineNum">    2217 </span>            :                 boost::throw_exception(promise_already_satisfied());
<span class="lineNum">    2218 </span>            :             }
<span class="lineNum">    2219 </span>            :             future_-&gt;mark_finished_with_result_internal(r, lock);
<span class="lineNum">    2220 </span>            :         }
<span class="lineNum">    2221 </span>            : 
<span class="lineNum">    2222 </span>            :         void set_exception(boost::exception_ptr p)
<span class="lineNum">    2223 </span>            :         {
<span class="lineNum">    2224 </span>            :             lazy_init();
<span class="lineNum">    2225 </span>            :             boost::unique_lock&lt;boost::mutex&gt; lock(future_-&gt;mutex);
<span class="lineNum">    2226 </span>            :             if(future_-&gt;done)
<span class="lineNum">    2227 </span>            :             {
<span class="lineNum">    2228 </span>            :                 boost::throw_exception(promise_already_satisfied());
<span class="lineNum">    2229 </span>            :             }
<span class="lineNum">    2230 </span>            :             future_-&gt;mark_exceptional_finish_internal(p, lock);
<span class="lineNum">    2231 </span>            :         }
<span class="lineNum">    2232 </span>            :         template &lt;typename E&gt;
<span class="lineNum">    2233 </span>            :         void set_exception(E ex)
<span class="lineNum">    2234 </span>            :         {
<span class="lineNum">    2235 </span>            :           set_exception(boost::copy_exception(ex));
<span class="lineNum">    2236 </span>            :         }
<span class="lineNum">    2237 </span>            : 
<span class="lineNum">    2238 </span>            :         // setting the result with deferred notification
<span class="lineNum">    2239 </span>            :         void set_value_at_thread_exit(R&amp; r)
<span class="lineNum">    2240 </span>            :         {
<span class="lineNum">    2241 </span>            :           if (future_.get()==0)
<span class="lineNum">    2242 </span>            :           {
<span class="lineNum">    2243 </span>            :               boost::throw_exception(promise_moved());
<span class="lineNum">    2244 </span>            :           }
<span class="lineNum">    2245 </span>            :           future_-&gt;set_value_at_thread_exit(r);
<span class="lineNum">    2246 </span>            :         }
<span class="lineNum">    2247 </span>            : 
<span class="lineNum">    2248 </span>            :         void set_exception_at_thread_exit(exception_ptr e)
<span class="lineNum">    2249 </span>            :         {
<span class="lineNum">    2250 </span>            :           if (future_.get()==0)
<span class="lineNum">    2251 </span>            :           {
<span class="lineNum">    2252 </span>            :               boost::throw_exception(promise_moved());
<span class="lineNum">    2253 </span>            :           }
<span class="lineNum">    2254 </span>            :           future_-&gt;set_exception_at_thread_exit(e);
<span class="lineNum">    2255 </span>            :         }
<span class="lineNum">    2256 </span>            :         template &lt;typename E&gt;
<span class="lineNum">    2257 </span>            :         void set_exception_at_thread_exit(E ex)
<span class="lineNum">    2258 </span>            :         {
<span class="lineNum">    2259 </span>            :           set_exception_at_thread_exit(boost::copy_exception(ex));
<span class="lineNum">    2260 </span>            :         }
<span class="lineNum">    2261 </span>            : 
<span class="lineNum">    2262 </span>            :         template&lt;typename F&gt;
<span class="lineNum">    2263 </span>            :         void set_wait_callback(F f)
<span class="lineNum">    2264 </span>            :         {
<span class="lineNum">    2265 </span>            :             lazy_init();
<span class="lineNum">    2266 </span>            :             future_-&gt;set_wait_callback(f,this);
<span class="lineNum">    2267 </span>            :         }
<span class="lineNum">    2268 </span>            :     };
<span class="lineNum">    2269 </span>            : 
<span class="lineNum">    2270 </span>            :     template &lt;&gt;
<span class="lineNum">    2271 </span>            :     class promise&lt;void&gt;
<span class="lineNum">    2272 </span>            :     {
<span class="lineNum">    2273 </span>            :         typedef boost::shared_ptr&lt;detail::shared_state&lt;void&gt; &gt; future_ptr;
<span class="lineNum">    2274 </span>            : 
<span class="lineNum">    2275 </span>            :         future_ptr future_;
<span class="lineNum">    2276 </span>            :         bool future_obtained;
<span class="lineNum">    2277 </span>            : 
<span class="lineNum">    2278 </span>            :         void lazy_init()
<span class="lineNum">    2279 </span>            :         {
<span class="lineNum">    2280 </span>            : #if defined BOOST_THREAD_PROVIDES_PROMISE_LAZY
<span class="lineNum">    2281 </span>            :             if(!atomic_load(&amp;future_))
<span class="lineNum">    2282 </span>            :             {
<span class="lineNum">    2283 </span>            :                 future_ptr blank;
<span class="lineNum">    2284 </span>            :                 atomic_compare_exchange(&amp;future_,&amp;blank,future_ptr(new detail::shared_state&lt;void&gt;));
<span class="lineNum">    2285 </span>            :             }
<span class="lineNum">    2286 </span>            : #endif
<span class="lineNum">    2287 </span>            :         }
<span class="lineNum">    2288 </span>            :     public:
<span class="lineNum">    2289 </span>            :         BOOST_THREAD_MOVABLE_ONLY(promise)
<span class="lineNum">    2290 </span>            : 
<span class="lineNum">    2291 </span>            : #if defined BOOST_THREAD_PROVIDES_FUTURE_CTOR_ALLOCATORS
<span class="lineNum">    2292 </span>            :         template &lt;class Allocator&gt;
<span class="lineNum">    2293 </span>            :         promise(boost::allocator_arg_t, Allocator a)
<span class="lineNum">    2294 </span>            :         {
<span class="lineNum">    2295 </span>            :           typedef typename Allocator::template rebind&lt;detail::shared_state&lt;void&gt; &gt;::other A2;
<span class="lineNum">    2296 </span>            :           A2 a2(a);
<span class="lineNum">    2297 </span>            :           typedef thread_detail::allocator_destructor&lt;A2&gt; D;
<span class="lineNum">    2298 </span>            : 
<span class="lineNum">    2299 </span>            :           future_ = future_ptr(::new(a2.allocate(1)) detail::shared_state&lt;void&gt;(), D(a2, 1) );
<span class="lineNum">    2300 </span>            :           future_obtained = false;
<span class="lineNum">    2301 </span>            :         }
<span class="lineNum">    2302 </span>            : #endif
<span class="lineNum">    2303 </span>            :         promise():
<span class="lineNum">    2304 </span>            : #if defined BOOST_THREAD_PROVIDES_PROMISE_LAZY
<span class="lineNum">    2305 </span>            :             future_(),
<span class="lineNum">    2306 </span>            : #else
<span class="lineNum">    2307 </span>            :             future_(new detail::shared_state&lt;void&gt;),
<span class="lineNum">    2308 </span>            : #endif
<span class="lineNum">    2309 </span>            :             future_obtained(false)
<span class="lineNum">    2310 </span>            :         {}
<span class="lineNum">    2311 </span>            : 
<span class="lineNum">    2312 </span>            :         ~promise()
<span class="lineNum">    2313 </span>            :         {
<span class="lineNum">    2314 </span>            :             if(future_)
<span class="lineNum">    2315 </span>            :             {
<span class="lineNum">    2316 </span>            :                 boost::unique_lock&lt;boost::mutex&gt; lock(future_-&gt;mutex);
<span class="lineNum">    2317 </span>            : 
<span class="lineNum">    2318 </span>            :                 if(!future_-&gt;done &amp;&amp; !future_-&gt;is_constructed)
<span class="lineNum">    2319 </span>            :                 {
<span class="lineNum">    2320 </span>            :                     future_-&gt;mark_exceptional_finish_internal(boost::copy_exception(broken_promise()), lock);
<span class="lineNum">    2321 </span>            :                 }
<span class="lineNum">    2322 </span>            :             }
<span class="lineNum">    2323 </span>            :         }
<span class="lineNum">    2324 </span>            : 
<span class="lineNum">    2325 </span>            :         // Assignment
<span class="lineNum">    2326 </span>            :         promise(BOOST_THREAD_RV_REF(promise) rhs) BOOST_NOEXCEPT :
<span class="lineNum">    2327 </span>            :             future_(BOOST_THREAD_RV(rhs).future_),future_obtained(BOOST_THREAD_RV(rhs).future_obtained)
<span class="lineNum">    2328 </span>            :         {
<span class="lineNum">    2329 </span>            :           // we need to release the future as shared_ptr doesn't implements move semantics
<span class="lineNum">    2330 </span>            :             BOOST_THREAD_RV(rhs).future_.reset();
<span class="lineNum">    2331 </span>            :             BOOST_THREAD_RV(rhs).future_obtained=false;
<span class="lineNum">    2332 </span>            :         }
<span class="lineNum">    2333 </span>            : 
<span class="lineNum">    2334 </span>            :         promise &amp; operator=(BOOST_THREAD_RV_REF(promise) rhs) BOOST_NOEXCEPT
<span class="lineNum">    2335 </span>            :         {
<span class="lineNum">    2336 </span>            :             future_=BOOST_THREAD_RV(rhs).future_;
<span class="lineNum">    2337 </span>            :             future_obtained=BOOST_THREAD_RV(rhs).future_obtained;
<span class="lineNum">    2338 </span>            :             BOOST_THREAD_RV(rhs).future_.reset();
<span class="lineNum">    2339 </span>            :             BOOST_THREAD_RV(rhs).future_obtained=false;
<span class="lineNum">    2340 </span>            :             return *this;
<span class="lineNum">    2341 </span>            :         }
<span class="lineNum">    2342 </span>            : 
<span class="lineNum">    2343 </span>            :         void swap(promise&amp; other)
<span class="lineNum">    2344 </span>            :         {
<span class="lineNum">    2345 </span>            :             future_.swap(other.future_);
<span class="lineNum">    2346 </span>            :             std::swap(future_obtained,other.future_obtained);
<span class="lineNum">    2347 </span>            :         }
<span class="lineNum">    2348 </span>            : 
<span class="lineNum">    2349 </span>            :         // Result retrieval
<span class="lineNum">    2350 </span>            :         BOOST_THREAD_FUTURE&lt;void&gt; get_future()
<span class="lineNum">    2351 </span>            :         {
<span class="lineNum">    2352 </span>            :             lazy_init();
<span class="lineNum">    2353 </span>            : 
<span class="lineNum">    2354 </span>            :             if (future_.get()==0)
<span class="lineNum">    2355 </span>            :             {
<span class="lineNum">    2356 </span>            :                 boost::throw_exception(promise_moved());
<span class="lineNum">    2357 </span>            :             }
<span class="lineNum">    2358 </span>            :             if(future_obtained)
<span class="lineNum">    2359 </span>            :             {
<span class="lineNum">    2360 </span>            :                 boost::throw_exception(future_already_retrieved());
<span class="lineNum">    2361 </span>            :             }
<span class="lineNum">    2362 </span>            :             future_obtained=true;
<span class="lineNum">    2363 </span>            :             //return BOOST_THREAD_MAKE_RV_REF(BOOST_THREAD_FUTURE&lt;void&gt;(future_));
<span class="lineNum">    2364 </span>            :             return BOOST_THREAD_FUTURE&lt;void&gt;(future_);
<span class="lineNum">    2365 </span>            :         }
<span class="lineNum">    2366 </span>            : 
<span class="lineNum">    2367 </span>            :         void set_value()
<span class="lineNum">    2368 </span>            :         {
<span class="lineNum">    2369 </span>            :             lazy_init();
<span class="lineNum">    2370 </span>            :             boost::unique_lock&lt;boost::mutex&gt; lock(future_-&gt;mutex);
<span class="lineNum">    2371 </span>            :             if(future_-&gt;done)
<span class="lineNum">    2372 </span>            :             {
<span class="lineNum">    2373 </span>            :                 boost::throw_exception(promise_already_satisfied());
<span class="lineNum">    2374 </span>            :             }
<span class="lineNum">    2375 </span>            :             future_-&gt;mark_finished_with_result_internal(lock);
<span class="lineNum">    2376 </span>            :         }
<span class="lineNum">    2377 </span>            : 
<span class="lineNum">    2378 </span>            :         void set_exception(boost::exception_ptr p)
<span class="lineNum">    2379 </span>            :         {
<span class="lineNum">    2380 </span>            :             lazy_init();
<span class="lineNum">    2381 </span>            :             boost::unique_lock&lt;boost::mutex&gt; lock(future_-&gt;mutex);
<span class="lineNum">    2382 </span>            :             if(future_-&gt;done)
<span class="lineNum">    2383 </span>            :             {
<span class="lineNum">    2384 </span>            :                 boost::throw_exception(promise_already_satisfied());
<span class="lineNum">    2385 </span>            :             }
<span class="lineNum">    2386 </span>            :             future_-&gt;mark_exceptional_finish_internal(p,lock);
<span class="lineNum">    2387 </span>            :         }
<span class="lineNum">    2388 </span>            :         template &lt;typename E&gt;
<span class="lineNum">    2389 </span>            :         void set_exception(E ex)
<span class="lineNum">    2390 </span>            :         {
<span class="lineNum">    2391 </span>            :           set_exception(boost::copy_exception(ex));
<span class="lineNum">    2392 </span>            :         }
<span class="lineNum">    2393 </span>            : 
<span class="lineNum">    2394 </span>            :         // setting the result with deferred notification
<span class="lineNum">    2395 </span>            :         void set_value_at_thread_exit()
<span class="lineNum">    2396 </span>            :         {
<span class="lineNum">    2397 </span>            :           if (future_.get()==0)
<span class="lineNum">    2398 </span>            :           {
<span class="lineNum">    2399 </span>            :               boost::throw_exception(promise_moved());
<span class="lineNum">    2400 </span>            :           }
<span class="lineNum">    2401 </span>            :           future_-&gt;set_value_at_thread_exit();
<span class="lineNum">    2402 </span>            :         }
<span class="lineNum">    2403 </span>            : 
<span class="lineNum">    2404 </span>            :         void set_exception_at_thread_exit(exception_ptr e)
<span class="lineNum">    2405 </span>            :         {
<span class="lineNum">    2406 </span>            :           if (future_.get()==0)
<span class="lineNum">    2407 </span>            :           {
<span class="lineNum">    2408 </span>            :               boost::throw_exception(promise_moved());
<span class="lineNum">    2409 </span>            :           }
<span class="lineNum">    2410 </span>            :           future_-&gt;set_exception_at_thread_exit(e);
<span class="lineNum">    2411 </span>            :         }
<span class="lineNum">    2412 </span>            :         template &lt;typename E&gt;
<span class="lineNum">    2413 </span>            :         void set_exception_at_thread_exit(E ex)
<span class="lineNum">    2414 </span>            :         {
<span class="lineNum">    2415 </span>            :           set_exception_at_thread_exit(boost::copy_exception(ex));
<span class="lineNum">    2416 </span>            :         }
<span class="lineNum">    2417 </span>            : 
<span class="lineNum">    2418 </span>            :         template&lt;typename F&gt;
<span class="lineNum">    2419 </span>            :         void set_wait_callback(F f)
<span class="lineNum">    2420 </span>            :         {
<span class="lineNum">    2421 </span>            :             lazy_init();
<span class="lineNum">    2422 </span>            :             future_-&gt;set_wait_callback(f,this);
<span class="lineNum">    2423 </span>            :         }
<span class="lineNum">    2424 </span>            : 
<span class="lineNum">    2425 </span>            :     };
<span class="lineNum">    2426 </span>            : }
<span class="lineNum">    2427 </span>            : #if defined BOOST_THREAD_PROVIDES_FUTURE_CTOR_ALLOCATORS
<span class="lineNum">    2428 </span>            : namespace boost { namespace container {
<span class="lineNum">    2429 </span>            :     template &lt;class R, class Alloc&gt;
<span class="lineNum">    2430 </span>            :     struct uses_allocator&lt; ::boost::promise&lt;R&gt; , Alloc&gt; : true_type
<span class="lineNum">    2431 </span>            :     {
<span class="lineNum">    2432 </span>            :     };
<span class="lineNum">    2433 </span>            : }}
<span class="lineNum">    2434 </span>            : #if ! defined  BOOST_NO_CXX11_ALLOCATOR
<span class="lineNum">    2435 </span>            : namespace std {
<span class="lineNum">    2436 </span>            :     template &lt;class R, class Alloc&gt;
<span class="lineNum">    2437 </span>            :     struct uses_allocator&lt; ::boost::promise&lt;R&gt; , Alloc&gt; : true_type
<span class="lineNum">    2438 </span>            :     {
<span class="lineNum">    2439 </span>            :     };
<span class="lineNum">    2440 </span>            : }
<span class="lineNum">    2441 </span>            : #endif
<span class="lineNum">    2442 </span>            : #endif
<span class="lineNum">    2443 </span>            : 
<span class="lineNum">    2444 </span>            : namespace boost
<span class="lineNum">    2445 </span>            : {
<span class="lineNum">    2446 </span>            : 
<span class="lineNum">    2447 </span>            :     BOOST_THREAD_DCL_MOVABLE_BEG(T) promise&lt;T&gt; BOOST_THREAD_DCL_MOVABLE_END
<span class="lineNum">    2448 </span>            : 
<span class="lineNum">    2449 </span>            :     namespace detail
<span class="lineNum">    2450 </span>            :     {
<span class="lineNum">    2451 </span>            : #if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK
<span class="lineNum">    2452 </span>            :       template&lt;typename R&gt;
<span class="lineNum">    2453 </span>            :       struct task_base_shared_state;
<span class="lineNum">    2454 </span>            : #if defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
<span class="lineNum">    2455 </span>            :       template&lt;typename R, typename ...ArgTypes&gt;
<span class="lineNum">    2456 </span>            :       struct task_base_shared_state&lt;R(ArgTypes...)&gt;:
<span class="lineNum">    2457 </span>            : #else
<span class="lineNum">    2458 </span>            :       template&lt;typename R&gt;
<span class="lineNum">    2459 </span>            :       struct task_base_shared_state&lt;R()&gt;:
<span class="lineNum">    2460 </span>            : #endif
<span class="lineNum">    2461 </span>            : #else
<span class="lineNum">    2462 </span>            :       template&lt;typename R&gt;
<span class="lineNum">    2463 </span><span class="lineNoCov">          0 :       struct task_base_shared_state:</span>
<span class="lineNum">    2464 </span>            : #endif
<span class="lineNum">    2465 </span>            :             detail::shared_state&lt;R&gt;
<span class="lineNum">    2466 </span>            :         {
<span class="lineNum">    2467 </span>            :             bool started;
<span class="lineNum">    2468 </span>            : 
<span class="lineNum">    2469 </span>            :             task_base_shared_state():
<span class="lineNum">    2470 </span>            :                 started(false)
<span class="lineNum">    2471 </span>            :             {}
<span class="lineNum">    2472 </span>            : 
<span class="lineNum">    2473 </span>            :             void reset()
<span class="lineNum">    2474 </span>            :             {
<span class="lineNum">    2475 </span>            :               // todo The packaged_task::reset must be as if an assignemnt froma new packaged_task with the same function
<span class="lineNum">    2476 </span>            :               // the reset function is an optimization that avoids reallocating a new task.
<span class="lineNum">    2477 </span>            :               started=false;
<span class="lineNum">    2478 </span>            :               this-&gt;validate();
<span class="lineNum">    2479 </span>            :             }
<span class="lineNum">    2480 </span>            : #if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK &amp;&amp; defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
<span class="lineNum">    2481 </span>            :             virtual void do_run(BOOST_THREAD_RV_REF(ArgTypes) ... args)=0;
<span class="lineNum">    2482 </span>            :             void run(BOOST_THREAD_RV_REF(ArgTypes) ... args)
<span class="lineNum">    2483 </span>            : #else
<span class="lineNum">    2484 </span>            :             virtual void do_run()=0;
<span class="lineNum">    2485 </span>            :             void run()
<span class="lineNum">    2486 </span>            : #endif
<span class="lineNum">    2487 </span>            :             {
<span class="lineNum">    2488 </span>            :                 {
<span class="lineNum">    2489 </span>            :                     boost::lock_guard&lt;boost::mutex&gt; lk(this-&gt;mutex);
<span class="lineNum">    2490 </span>            :                     if(started)
<span class="lineNum">    2491 </span>            :                     {
<span class="lineNum">    2492 </span>            :                         boost::throw_exception(task_already_started());
<span class="lineNum">    2493 </span>            :                     }
<span class="lineNum">    2494 </span>            :                     started=true;
<span class="lineNum">    2495 </span>            :                 }
<span class="lineNum">    2496 </span>            : #if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK &amp;&amp; defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
<span class="lineNum">    2497 </span>            :                 do_run(boost::move(args)...);
<span class="lineNum">    2498 </span>            : #else
<span class="lineNum">    2499 </span>            :                 do_run();
<span class="lineNum">    2500 </span>            : #endif
<span class="lineNum">    2501 </span>            :             }
<span class="lineNum">    2502 </span>            : 
<span class="lineNum">    2503 </span>            : #if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK &amp;&amp; defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
<span class="lineNum">    2504 </span>            :             virtual void do_apply(BOOST_THREAD_RV_REF(ArgTypes) ... args)=0;
<span class="lineNum">    2505 </span>            :             void apply(BOOST_THREAD_RV_REF(ArgTypes) ... args)
<span class="lineNum">    2506 </span>            : #else
<span class="lineNum">    2507 </span>            :             virtual void do_apply()=0;
<span class="lineNum">    2508 </span>            :             void apply()
<span class="lineNum">    2509 </span>            : #endif
<span class="lineNum">    2510 </span>            :             {
<span class="lineNum">    2511 </span>            :                 {
<span class="lineNum">    2512 </span>            :                     boost::lock_guard&lt;boost::mutex&gt; lk(this-&gt;mutex);
<span class="lineNum">    2513 </span>            :                     if(started)
<span class="lineNum">    2514 </span>            :                     {
<span class="lineNum">    2515 </span>            :                         boost::throw_exception(task_already_started());
<span class="lineNum">    2516 </span>            :                     }
<span class="lineNum">    2517 </span>            :                     started=true;
<span class="lineNum">    2518 </span>            :                 }
<span class="lineNum">    2519 </span>            : #if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK &amp;&amp; defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
<span class="lineNum">    2520 </span>            :                 do_apply(boost::move(args)...);
<span class="lineNum">    2521 </span>            : #else
<span class="lineNum">    2522 </span>            :                 do_apply();
<span class="lineNum">    2523 </span>            : #endif
<span class="lineNum">    2524 </span>            :             }
<span class="lineNum">    2525 </span>            : 
<span class="lineNum">    2526 </span>            :             void owner_destroyed()
<span class="lineNum">    2527 </span>            :             {
<span class="lineNum">    2528 </span>            :                 boost::unique_lock&lt;boost::mutex&gt; lk(this-&gt;mutex);
<span class="lineNum">    2529 </span>            :                 if(!started)
<span class="lineNum">    2530 </span>            :                 {
<span class="lineNum">    2531 </span>            :                     started=true;
<span class="lineNum">    2532 </span>            :                     this-&gt;mark_exceptional_finish_internal(boost::copy_exception(boost::broken_promise()), lk);
<span class="lineNum">    2533 </span>            :                 }
<span class="lineNum">    2534 </span>            :             }
<span class="lineNum">    2535 </span>            :         };
<span class="lineNum">    2536 </span>            : 
<span class="lineNum">    2537 </span>            : #if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK
<span class="lineNum">    2538 </span>            :         template&lt;typename F, typename R&gt;
<span class="lineNum">    2539 </span>            :         struct task_shared_state;
<span class="lineNum">    2540 </span>            : #if defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
<span class="lineNum">    2541 </span>            :         template&lt;typename F, typename R, typename ...ArgTypes&gt;
<span class="lineNum">    2542 </span>            :         struct task_shared_state&lt;F, R(ArgTypes...)&gt;:
<span class="lineNum">    2543 </span>            :           task_base_shared_state&lt;R(ArgTypes...)&gt;
<span class="lineNum">    2544 </span>            : #else
<span class="lineNum">    2545 </span>            :         template&lt;typename F, typename R&gt;
<span class="lineNum">    2546 </span>            :         struct task_shared_state&lt;F, R()&gt;:
<span class="lineNum">    2547 </span>            :           task_base_shared_state&lt;R()&gt;
<span class="lineNum">    2548 </span>            : #endif
<span class="lineNum">    2549 </span>            : #else
<span class="lineNum">    2550 </span>            :         template&lt;typename F, typename R&gt;
<span class="lineNum">    2551 </span>            :         struct task_shared_state:
<span class="lineNum">    2552 </span>            :             task_base_shared_state&lt;R&gt;
<span class="lineNum">    2553 </span>            : #endif
<span class="lineNum">    2554 </span>            :         {
<span class="lineNum">    2555 </span>            :         private:
<span class="lineNum">    2556 </span>            :           task_shared_state(task_shared_state&amp;);
<span class="lineNum">    2557 </span>            :         public:
<span class="lineNum">    2558 </span>            :             F f;
<span class="lineNum">    2559 </span>            :             task_shared_state(F const&amp; f_):
<span class="lineNum">    2560 </span>            :                 f(f_)
<span class="lineNum">    2561 </span>            :             {}
<span class="lineNum">    2562 </span>            :             task_shared_state(BOOST_THREAD_RV_REF(F) f_):
<span class="lineNum">    2563 </span>            :               f(boost::move(f_))
<span class="lineNum">    2564 </span>            :             {}
<span class="lineNum">    2565 </span>            : 
<span class="lineNum">    2566 </span>            :             F callable()
<span class="lineNum">    2567 </span>            :             {
<span class="lineNum">    2568 </span>            :               return boost::move(f);
<span class="lineNum">    2569 </span>            :             }
<span class="lineNum">    2570 </span>            : 
<span class="lineNum">    2571 </span>            : #if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK &amp;&amp; defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
<span class="lineNum">    2572 </span>            :             void do_apply(BOOST_THREAD_RV_REF(ArgTypes) ... args)
<span class="lineNum">    2573 </span>            :             {
<span class="lineNum">    2574 </span>            :                 try
<span class="lineNum">    2575 </span>            :                 {
<span class="lineNum">    2576 </span>            :                     this-&gt;set_value_at_thread_exit(f(boost::move(args)...));
<span class="lineNum">    2577 </span>            :                 }
<span class="lineNum">    2578 </span>            : #else
<span class="lineNum">    2579 </span>            :             void do_apply()
<span class="lineNum">    2580 </span>            :             {
<span class="lineNum">    2581 </span>            :                 try
<span class="lineNum">    2582 </span>            :                 {
<span class="lineNum">    2583 </span>            :                     this-&gt;set_value_at_thread_exit(f());
<span class="lineNum">    2584 </span>            :                 }
<span class="lineNum">    2585 </span>            : #endif
<span class="lineNum">    2586 </span>            :                 catch(...)
<span class="lineNum">    2587 </span>            :                 {
<span class="lineNum">    2588 </span>            :                     this-&gt;set_exception_at_thread_exit(current_exception());
<span class="lineNum">    2589 </span>            :                 }
<span class="lineNum">    2590 </span>            :             }
<span class="lineNum">    2591 </span>            : 
<span class="lineNum">    2592 </span>            : #if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK &amp;&amp; defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
<span class="lineNum">    2593 </span>            :             void do_run(BOOST_THREAD_RV_REF(ArgTypes) ... args)
<span class="lineNum">    2594 </span>            :             {
<span class="lineNum">    2595 </span>            :                 try
<span class="lineNum">    2596 </span>            :                 {
<span class="lineNum">    2597 </span>            :                     this-&gt;mark_finished_with_result(f(boost::move(args)...));
<span class="lineNum">    2598 </span>            :                 }
<span class="lineNum">    2599 </span>            : #else
<span class="lineNum">    2600 </span>            :             void do_run()
<span class="lineNum">    2601 </span>            :             {
<span class="lineNum">    2602 </span>            :                 try
<span class="lineNum">    2603 </span>            :                 {
<span class="lineNum">    2604 </span>            : #if ! defined  BOOST_NO_CXX11_RVALUE_REFERENCES
<span class="lineNum">    2605 </span>            :                   R res((f()));
<span class="lineNum">    2606 </span>            :                   this-&gt;mark_finished_with_result(boost::move(res));
<span class="lineNum">    2607 </span>            : #else
<span class="lineNum">    2608 </span>            :                   this-&gt;mark_finished_with_result(f());
<span class="lineNum">    2609 </span>            : #endif
<span class="lineNum">    2610 </span>            :                   }
<span class="lineNum">    2611 </span>            : #endif
<span class="lineNum">    2612 </span>            :                 catch(...)
<span class="lineNum">    2613 </span>            :                 {
<span class="lineNum">    2614 </span>            :                     this-&gt;mark_exceptional_finish();
<span class="lineNum">    2615 </span>            :                 }
<span class="lineNum">    2616 </span>            :             }
<span class="lineNum">    2617 </span>            :         };
<span class="lineNum">    2618 </span>            : 
<span class="lineNum">    2619 </span>            : #if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK
<span class="lineNum">    2620 </span>            : #if defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
<span class="lineNum">    2621 </span>            :         template&lt;typename F, typename R, typename ...ArgTypes&gt;
<span class="lineNum">    2622 </span>            :         struct task_shared_state&lt;F, R&amp;(ArgTypes...)&gt;:
<span class="lineNum">    2623 </span>            :           task_base_shared_state&lt;R&amp;(ArgTypes...)&gt;
<span class="lineNum">    2624 </span>            : #else
<span class="lineNum">    2625 </span>            :         template&lt;typename F, typename R&gt;
<span class="lineNum">    2626 </span>            :         struct task_shared_state&lt;F, R&amp;()&gt;:
<span class="lineNum">    2627 </span>            :           task_base_shared_state&lt;R&amp;()&gt;
<span class="lineNum">    2628 </span>            : #endif
<span class="lineNum">    2629 </span>            : #else
<span class="lineNum">    2630 </span>            :         template&lt;typename F, typename R&gt;
<span class="lineNum">    2631 </span>            :         struct task_shared_state&lt;F,R&amp;&gt;:
<span class="lineNum">    2632 </span>            :             task_base_shared_state&lt;R&amp;&gt;
<span class="lineNum">    2633 </span>            : #endif
<span class="lineNum">    2634 </span>            :         {
<span class="lineNum">    2635 </span>            :         private:
<span class="lineNum">    2636 </span>            :           task_shared_state(task_shared_state&amp;);
<span class="lineNum">    2637 </span>            :         public:
<span class="lineNum">    2638 </span>            :             F f;
<span class="lineNum">    2639 </span>            :             task_shared_state(F const&amp; f_):
<span class="lineNum">    2640 </span>            :                 f(f_)
<span class="lineNum">    2641 </span>            :             {}
<span class="lineNum">    2642 </span>            :             task_shared_state(BOOST_THREAD_RV_REF(F) f_):
<span class="lineNum">    2643 </span>            :                 f(boost::move(f_))
<span class="lineNum">    2644 </span>            :             {}
<span class="lineNum">    2645 </span>            : 
<span class="lineNum">    2646 </span>            :             F callable()
<span class="lineNum">    2647 </span>            :             {
<span class="lineNum">    2648 </span>            :               return f;
<span class="lineNum">    2649 </span>            :             }
<span class="lineNum">    2650 </span>            : 
<span class="lineNum">    2651 </span>            : #if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK &amp;&amp; defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
<span class="lineNum">    2652 </span>            :             void do_apply(BOOST_THREAD_RV_REF(ArgTypes) ... args)
<span class="lineNum">    2653 </span>            :             {
<span class="lineNum">    2654 </span>            :                 try
<span class="lineNum">    2655 </span>            :                 {
<span class="lineNum">    2656 </span>            :                     this-&gt;set_value_at_thread_exit(f(boost::move(args)...));
<span class="lineNum">    2657 </span>            :                 }
<span class="lineNum">    2658 </span>            : #else
<span class="lineNum">    2659 </span>            :             void do_apply()
<span class="lineNum">    2660 </span>            :             {
<span class="lineNum">    2661 </span>            :                 try
<span class="lineNum">    2662 </span>            :                 {
<span class="lineNum">    2663 </span>            :                     this-&gt;set_value_at_thread_exit(f());
<span class="lineNum">    2664 </span>            :                 }
<span class="lineNum">    2665 </span>            : #endif
<span class="lineNum">    2666 </span>            :                 catch(...)
<span class="lineNum">    2667 </span>            :                 {
<span class="lineNum">    2668 </span>            :                     this-&gt;set_exception_at_thread_exit(current_exception());
<span class="lineNum">    2669 </span>            :                 }
<span class="lineNum">    2670 </span>            :             }
<span class="lineNum">    2671 </span>            : 
<span class="lineNum">    2672 </span>            : #if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK &amp;&amp; defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
<span class="lineNum">    2673 </span>            :             void do_run(BOOST_THREAD_RV_REF(ArgTypes) ... args)
<span class="lineNum">    2674 </span>            :             {
<span class="lineNum">    2675 </span>            :                 try
<span class="lineNum">    2676 </span>            :                 {
<span class="lineNum">    2677 </span>            :                     this-&gt;mark_finished_with_result(f(boost::move(args)...));
<span class="lineNum">    2678 </span>            :                 }
<span class="lineNum">    2679 </span>            : #else
<span class="lineNum">    2680 </span>            :             void do_run()
<span class="lineNum">    2681 </span>            :             {
<span class="lineNum">    2682 </span>            :                 try
<span class="lineNum">    2683 </span>            :                 {
<span class="lineNum">    2684 </span>            :                   R&amp; res((f()));
<span class="lineNum">    2685 </span>            :                   this-&gt;mark_finished_with_result(res);
<span class="lineNum">    2686 </span>            :                 }
<span class="lineNum">    2687 </span>            : #endif
<span class="lineNum">    2688 </span>            :                 catch(...)
<span class="lineNum">    2689 </span>            :                 {
<span class="lineNum">    2690 </span>            :                     this-&gt;mark_exceptional_finish();
<span class="lineNum">    2691 </span>            :                 }
<span class="lineNum">    2692 </span>            :             }
<span class="lineNum">    2693 </span>            :         };
<span class="lineNum">    2694 </span>            : 
<span class="lineNum">    2695 </span>            : #if defined(BOOST_THREAD_RVALUE_REFERENCES_DONT_MATCH_FUNTION_PTR)
<span class="lineNum">    2696 </span>            : 
<span class="lineNum">    2697 </span>            : #if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK
<span class="lineNum">    2698 </span>            : #if defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
<span class="lineNum">    2699 </span>            :         template&lt;typename R, typename ...ArgTypes&gt;
<span class="lineNum">    2700 </span>            :         struct task_shared_state&lt;R (*)(ArgTypes...), R(ArgTypes...)&gt;:
<span class="lineNum">    2701 </span>            :           task_base_shared_state&lt;R(ArgTypes...)&gt;
<span class="lineNum">    2702 </span>            : #else
<span class="lineNum">    2703 </span>            :         template&lt;typename R&gt;
<span class="lineNum">    2704 </span>            :         struct task_shared_state&lt;R (*)(), R()&gt;:
<span class="lineNum">    2705 </span>            :           task_base_shared_state&lt;R()&gt;
<span class="lineNum">    2706 </span>            : #endif
<span class="lineNum">    2707 </span>            : #else
<span class="lineNum">    2708 </span>            :         template&lt;typename R&gt;
<span class="lineNum">    2709 </span>            :         struct task_shared_state&lt;R (*)(), R&gt; :
<span class="lineNum">    2710 </span>            :            task_base_shared_state&lt;R&gt;
<span class="lineNum">    2711 </span>            : #endif
<span class="lineNum">    2712 </span>            :             {
<span class="lineNum">    2713 </span>            :             private:
<span class="lineNum">    2714 </span>            :               task_shared_state(task_shared_state&amp;);
<span class="lineNum">    2715 </span>            : #if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK &amp;&amp; defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
<span class="lineNum">    2716 </span>            :               typedef R (*CallableType)(BOOST_THREAD_RV_REF(ArgTypes) ... );
<span class="lineNum">    2717 </span>            : #else
<span class="lineNum">    2718 </span>            :               typedef R (*CallableType)();
<span class="lineNum">    2719 </span>            : #endif
<span class="lineNum">    2720 </span>            :             public:
<span class="lineNum">    2721 </span>            :                 CallableType f;
<span class="lineNum">    2722 </span>            :                 task_shared_state(CallableType f_):
<span class="lineNum">    2723 </span>            :                     f(f_)
<span class="lineNum">    2724 </span>            :                 {}
<span class="lineNum">    2725 </span>            : 
<span class="lineNum">    2726 </span>            :                 CallableType callable()
<span class="lineNum">    2727 </span>            :                 {
<span class="lineNum">    2728 </span>            :                   return f;
<span class="lineNum">    2729 </span>            :                 }
<span class="lineNum">    2730 </span>            : 
<span class="lineNum">    2731 </span>            : #if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK &amp;&amp; defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
<span class="lineNum">    2732 </span>            :                 void do_apply(BOOST_THREAD_RV_REF(ArgTypes) ... args)
<span class="lineNum">    2733 </span>            :                 {
<span class="lineNum">    2734 </span>            :                     try
<span class="lineNum">    2735 </span>            :                     {
<span class="lineNum">    2736 </span>            :                         this-&gt;set_value_at_thread_exit(f(boost::move(args)...));
<span class="lineNum">    2737 </span>            :                     }
<span class="lineNum">    2738 </span>            : #else
<span class="lineNum">    2739 </span>            :                 void do_apply()
<span class="lineNum">    2740 </span>            :                 {
<span class="lineNum">    2741 </span>            :                     try
<span class="lineNum">    2742 </span>            :                     {
<span class="lineNum">    2743 </span>            :                         R r((f()));
<span class="lineNum">    2744 </span>            :                         this-&gt;set_value_at_thread_exit(boost::move(r));
<span class="lineNum">    2745 </span>            :                     }
<span class="lineNum">    2746 </span>            : #endif
<span class="lineNum">    2747 </span>            :                     catch(...)
<span class="lineNum">    2748 </span>            :                     {
<span class="lineNum">    2749 </span>            :                         this-&gt;set_exception_at_thread_exit(current_exception());
<span class="lineNum">    2750 </span>            :                     }
<span class="lineNum">    2751 </span>            :                 }
<span class="lineNum">    2752 </span>            : 
<span class="lineNum">    2753 </span>            : 
<span class="lineNum">    2754 </span>            : #if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK &amp;&amp; defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
<span class="lineNum">    2755 </span>            :                 void do_run(BOOST_THREAD_RV_REF(ArgTypes) ... args)
<span class="lineNum">    2756 </span>            :                 {
<span class="lineNum">    2757 </span>            :                     try
<span class="lineNum">    2758 </span>            :                     {
<span class="lineNum">    2759 </span>            :                         this-&gt;mark_finished_with_result(f(boost::move(args)...));
<span class="lineNum">    2760 </span>            :                     }
<span class="lineNum">    2761 </span>            : #else
<span class="lineNum">    2762 </span>            :                 void do_run()
<span class="lineNum">    2763 </span>            :                 {
<span class="lineNum">    2764 </span>            :                     try
<span class="lineNum">    2765 </span>            :                     {
<span class="lineNum">    2766 </span>            :                         R res((f()));
<span class="lineNum">    2767 </span>            :                         this-&gt;mark_finished_with_result(boost::move(res));
<span class="lineNum">    2768 </span>            :                     }
<span class="lineNum">    2769 </span>            : #endif
<span class="lineNum">    2770 </span>            :                     catch(...)
<span class="lineNum">    2771 </span>            :                     {
<span class="lineNum">    2772 </span>            :                         this-&gt;mark_exceptional_finish();
<span class="lineNum">    2773 </span>            :                     }
<span class="lineNum">    2774 </span>            :                 }
<span class="lineNum">    2775 </span>            :             };
<span class="lineNum">    2776 </span>            : #if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK
<span class="lineNum">    2777 </span>            : #if defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
<span class="lineNum">    2778 </span>            :         template&lt;typename R, typename ...ArgTypes&gt;
<span class="lineNum">    2779 </span>            :         struct task_shared_state&lt;R&amp; (*)(ArgTypes...), R&amp;(ArgTypes...)&gt;:
<span class="lineNum">    2780 </span>            :           task_base_shared_state&lt;R&amp;(ArgTypes...)&gt;
<span class="lineNum">    2781 </span>            : #else
<span class="lineNum">    2782 </span>            :         template&lt;typename R&gt;
<span class="lineNum">    2783 </span>            :         struct task_shared_state&lt;R&amp; (*)(), R&amp;()&gt;:
<span class="lineNum">    2784 </span>            :           task_base_shared_state&lt;R&amp;()&gt;
<span class="lineNum">    2785 </span>            : #endif
<span class="lineNum">    2786 </span>            : #else
<span class="lineNum">    2787 </span>            :         template&lt;typename R&gt;
<span class="lineNum">    2788 </span>            :         struct task_shared_state&lt;R&amp; (*)(), R&amp;&gt; :
<span class="lineNum">    2789 </span>            :            task_base_shared_state&lt;R&amp;&gt;
<span class="lineNum">    2790 </span>            : #endif
<span class="lineNum">    2791 </span>            :             {
<span class="lineNum">    2792 </span>            :             private:
<span class="lineNum">    2793 </span>            :               task_shared_state(task_shared_state&amp;);
<span class="lineNum">    2794 </span>            :             public:
<span class="lineNum">    2795 </span>            : #if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK &amp;&amp; defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
<span class="lineNum">    2796 </span>            :                 typedef R&amp; (*CallableType)(BOOST_THREAD_RV_REF(ArgTypes) ... );
<span class="lineNum">    2797 </span>            : #else
<span class="lineNum">    2798 </span>            :                 typedef R&amp; (*CallableType)();
<span class="lineNum">    2799 </span>            : #endif
<span class="lineNum">    2800 </span>            :                 CallableType f;
<span class="lineNum">    2801 </span>            :                 task_shared_state(CallableType f_):
<span class="lineNum">    2802 </span>            :                     f(f_)
<span class="lineNum">    2803 </span>            :                 {}
<span class="lineNum">    2804 </span>            : 
<span class="lineNum">    2805 </span>            :                 CallableType callable()
<span class="lineNum">    2806 </span>            :                 {
<span class="lineNum">    2807 </span>            :                   return boost::move(f);
<span class="lineNum">    2808 </span>            :                 }
<span class="lineNum">    2809 </span>            : 
<span class="lineNum">    2810 </span>            : #if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK &amp;&amp; defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
<span class="lineNum">    2811 </span>            :                 void do_apply(BOOST_THREAD_RV_REF(ArgTypes) ... args)
<span class="lineNum">    2812 </span>            :                 {
<span class="lineNum">    2813 </span>            :                     try
<span class="lineNum">    2814 </span>            :                     {
<span class="lineNum">    2815 </span>            :                         this-&gt;set_value_at_thread_exit(f(boost::move(args)...));
<span class="lineNum">    2816 </span>            :                     }
<span class="lineNum">    2817 </span>            : #else
<span class="lineNum">    2818 </span>            :                 void do_apply()
<span class="lineNum">    2819 </span>            :                 {
<span class="lineNum">    2820 </span>            :                     try
<span class="lineNum">    2821 </span>            :                     {
<span class="lineNum">    2822 </span>            :                       this-&gt;set_value_at_thread_exit(f());
<span class="lineNum">    2823 </span>            :                     }
<span class="lineNum">    2824 </span>            : #endif
<span class="lineNum">    2825 </span>            :                     catch(...)
<span class="lineNum">    2826 </span>            :                     {
<span class="lineNum">    2827 </span>            :                         this-&gt;set_exception_at_thread_exit(current_exception());
<span class="lineNum">    2828 </span>            :                     }
<span class="lineNum">    2829 </span>            :                 }
<span class="lineNum">    2830 </span>            : 
<span class="lineNum">    2831 </span>            : 
<span class="lineNum">    2832 </span>            : #if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK &amp;&amp; defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
<span class="lineNum">    2833 </span>            :                 void do_run(BOOST_THREAD_RV_REF(ArgTypes) ... args)
<span class="lineNum">    2834 </span>            :                 {
<span class="lineNum">    2835 </span>            :                     try
<span class="lineNum">    2836 </span>            :                     {
<span class="lineNum">    2837 </span>            :                         this-&gt;mark_finished_with_result(f(boost::move(args)...));
<span class="lineNum">    2838 </span>            :                     }
<span class="lineNum">    2839 </span>            : #else
<span class="lineNum">    2840 </span>            :                 void do_run()
<span class="lineNum">    2841 </span>            :                 {
<span class="lineNum">    2842 </span>            :                     try
<span class="lineNum">    2843 </span>            :                     {
<span class="lineNum">    2844 </span>            :                         this-&gt;mark_finished_with_result(f());
<span class="lineNum">    2845 </span>            :                     }
<span class="lineNum">    2846 </span>            : #endif
<span class="lineNum">    2847 </span>            :                     catch(...)
<span class="lineNum">    2848 </span>            :                     {
<span class="lineNum">    2849 </span>            :                         this-&gt;mark_exceptional_finish();
<span class="lineNum">    2850 </span>            :                     }
<span class="lineNum">    2851 </span>            :                 }
<span class="lineNum">    2852 </span>            :             };
<span class="lineNum">    2853 </span>            : #endif
<span class="lineNum">    2854 </span>            : #if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK
<span class="lineNum">    2855 </span>            : #if defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
<span class="lineNum">    2856 </span>            :         template&lt;typename F, typename ...ArgTypes&gt;
<span class="lineNum">    2857 </span>            :         struct task_shared_state&lt;F, void(ArgTypes...)&gt;:
<span class="lineNum">    2858 </span>            :           task_base_shared_state&lt;void(ArgTypes...)&gt;
<span class="lineNum">    2859 </span>            : #else
<span class="lineNum">    2860 </span>            :         template&lt;typename F&gt;
<span class="lineNum">    2861 </span>            :         struct task_shared_state&lt;F, void()&gt;:
<span class="lineNum">    2862 </span>            :           task_base_shared_state&lt;void()&gt;
<span class="lineNum">    2863 </span>            : #endif
<span class="lineNum">    2864 </span>            : #else
<span class="lineNum">    2865 </span>            :         template&lt;typename F&gt;
<span class="lineNum">    2866 </span>            :         struct task_shared_state&lt;F,void&gt;:
<span class="lineNum">    2867 </span>            :           task_base_shared_state&lt;void&gt;
<span class="lineNum">    2868 </span>            : #endif
<span class="lineNum">    2869 </span>            :         {
<span class="lineNum">    2870 </span>            :         private:
<span class="lineNum">    2871 </span>            :           task_shared_state(task_shared_state&amp;);
<span class="lineNum">    2872 </span>            :         public:
<span class="lineNum">    2873 </span>            :             typedef F CallableType;
<span class="lineNum">    2874 </span>            :             F f;
<span class="lineNum">    2875 </span>            :             task_shared_state(F const&amp; f_):
<span class="lineNum">    2876 </span>            :                 f(f_)
<span class="lineNum">    2877 </span>            :             {}
<span class="lineNum">    2878 </span>            :             task_shared_state(BOOST_THREAD_RV_REF(F) f_):
<span class="lineNum">    2879 </span>            :                 f(boost::move(f_))
<span class="lineNum">    2880 </span>            :             {}
<span class="lineNum">    2881 </span>            :             F callable()
<span class="lineNum">    2882 </span>            :             {
<span class="lineNum">    2883 </span>            :               return boost::move(f);
<span class="lineNum">    2884 </span>            :             }
<span class="lineNum">    2885 </span>            : #if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK &amp;&amp; defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
<span class="lineNum">    2886 </span>            :             void do_apply(BOOST_THREAD_RV_REF(ArgTypes) ... args)
<span class="lineNum">    2887 </span>            :             {
<span class="lineNum">    2888 </span>            :               try
<span class="lineNum">    2889 </span>            :               {
<span class="lineNum">    2890 </span>            :                 f(boost::move(args)...);
<span class="lineNum">    2891 </span>            : #else
<span class="lineNum">    2892 </span>            :             void do_apply()
<span class="lineNum">    2893 </span>            :             {
<span class="lineNum">    2894 </span>            :                 try
<span class="lineNum">    2895 </span>            :                 {
<span class="lineNum">    2896 </span>            :                     f();
<span class="lineNum">    2897 </span>            : #endif
<span class="lineNum">    2898 </span>            :                   this-&gt;set_value_at_thread_exit();
<span class="lineNum">    2899 </span>            :                 }
<span class="lineNum">    2900 </span>            :                 catch(...)
<span class="lineNum">    2901 </span>            :                 {
<span class="lineNum">    2902 </span>            :                     this-&gt;set_exception_at_thread_exit(current_exception());
<span class="lineNum">    2903 </span>            :                 }
<span class="lineNum">    2904 </span>            :             }
<span class="lineNum">    2905 </span>            : 
<span class="lineNum">    2906 </span>            : #if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK &amp;&amp; defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
<span class="lineNum">    2907 </span>            :             void do_run(BOOST_THREAD_RV_REF(ArgTypes) ... args)
<span class="lineNum">    2908 </span>            :             {
<span class="lineNum">    2909 </span>            :                 try
<span class="lineNum">    2910 </span>            :                 {
<span class="lineNum">    2911 </span>            :                     f(boost::move(args)...);
<span class="lineNum">    2912 </span>            : #else
<span class="lineNum">    2913 </span>            :             void do_run()
<span class="lineNum">    2914 </span>            :             {
<span class="lineNum">    2915 </span>            :                 try
<span class="lineNum">    2916 </span>            :                 {
<span class="lineNum">    2917 </span>            :                     f();
<span class="lineNum">    2918 </span>            : #endif
<span class="lineNum">    2919 </span>            :                     this-&gt;mark_finished_with_result();
<span class="lineNum">    2920 </span>            :                 }
<span class="lineNum">    2921 </span>            :                 catch(...)
<span class="lineNum">    2922 </span>            :                 {
<span class="lineNum">    2923 </span>            :                     this-&gt;mark_exceptional_finish();
<span class="lineNum">    2924 </span>            :                 }
<span class="lineNum">    2925 </span>            :             }
<span class="lineNum">    2926 </span>            :         };
<span class="lineNum">    2927 </span>            : 
<span class="lineNum">    2928 </span>            : #if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK
<span class="lineNum">    2929 </span>            : #if defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
<span class="lineNum">    2930 </span>            :         template&lt;typename ...ArgTypes&gt;
<span class="lineNum">    2931 </span>            :         struct task_shared_state&lt;void (*)(ArgTypes...), void(ArgTypes...)&gt;:
<span class="lineNum">    2932 </span>            :         task_base_shared_state&lt;void(ArgTypes...)&gt;
<span class="lineNum">    2933 </span>            : #else
<span class="lineNum">    2934 </span>            :         template&lt;&gt;
<span class="lineNum">    2935 </span>            :         struct task_shared_state&lt;void (*)(), void()&gt;:
<span class="lineNum">    2936 </span>            :         task_base_shared_state&lt;void()&gt;
<span class="lineNum">    2937 </span>            : #endif
<a name="2938"><span class="lineNum">    2938 </span>            : #else</a>
<span class="lineNum">    2939 </span>            :         template&lt;&gt;
<span class="lineNum">    2940 </span><span class="lineNoCov">          0 :         struct task_shared_state&lt;void (*)(),void&gt;:</span>
<span class="lineNum">    2941 </span>            :           task_base_shared_state&lt;void&gt;
<span class="lineNum">    2942 </span>            : #endif
<span class="lineNum">    2943 </span>            :         {
<span class="lineNum">    2944 </span>            :         private:
<span class="lineNum">    2945 </span>            :           task_shared_state(task_shared_state&amp;);
<span class="lineNum">    2946 </span>            : #if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK &amp;&amp; defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
<span class="lineNum">    2947 </span>            :             typedef void (*CallableType)(BOOST_THREAD_RV_REF(ArgTypes)...);
<span class="lineNum">    2948 </span>            : #else
<span class="lineNum">    2949 </span>            :             typedef void (*CallableType)();
<span class="lineNum">    2950 </span>            : #endif
<span class="lineNum">    2951 </span>            :         public:
<span class="lineNum">    2952 </span>            :             CallableType f;
<span class="lineNum">    2953 </span>            :             task_shared_state(CallableType f_):
<span class="lineNum">    2954 </span>            :                 f(f_)
<span class="lineNum">    2955 </span>            :             {}
<span class="lineNum">    2956 </span>            :             CallableType callable()
<span class="lineNum">    2957 </span>            :             {
<span class="lineNum">    2958 </span>            :               return f;
<span class="lineNum">    2959 </span>            :             }
<span class="lineNum">    2960 </span>            : #if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK &amp;&amp; defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
<span class="lineNum">    2961 </span>            :             void do_apply(BOOST_THREAD_RV_REF(ArgTypes) ... args)
<span class="lineNum">    2962 </span>            :             {
<span class="lineNum">    2963 </span>            :                 try
<span class="lineNum">    2964 </span>            :                 {
<a name="2965"><span class="lineNum">    2965 </span>            :                     f(boost::move(args)...);</a>
<span class="lineNum">    2966 </span>            : #else
<span class="lineNum">    2967 </span><span class="lineNoCov">          0 :             void do_apply()</span>
<span class="lineNum">    2968 </span>            :             {
<span class="lineNum">    2969 </span>            :                 try
<span class="lineNum">    2970 </span>            :                 {
<span class="lineNum">    2971 </span><span class="lineNoCov">          0 :                     f();</span>
<span class="lineNum">    2972 </span>            : #endif
<span class="lineNum">    2973 </span><span class="lineNoCov">          0 :                     this-&gt;set_value_at_thread_exit();</span>
<span class="lineNum">    2974 </span>            :                 }
<span class="lineNum">    2975 </span><span class="lineNoCov">          0 :                 catch(...)</span>
<span class="lineNum">    2976 </span>            :                 {
<span class="lineNum">    2977 </span><span class="lineNoCov">          0 :                     this-&gt;set_exception_at_thread_exit(current_exception());</span>
<span class="lineNum">    2978 </span>            :                 }
<span class="lineNum">    2979 </span><span class="lineNoCov">          0 :             }</span>
<span class="lineNum">    2980 </span>            : 
<span class="lineNum">    2981 </span>            : #if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK &amp;&amp; defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
<span class="lineNum">    2982 </span>            :             void do_run(BOOST_THREAD_RV_REF(ArgTypes) ... args)
<span class="lineNum">    2983 </span>            :             {
<span class="lineNum">    2984 </span>            :                 try
<span class="lineNum">    2985 </span>            :                 {
<a name="2986"><span class="lineNum">    2986 </span>            :                     f(boost::move(args)...);</a>
<span class="lineNum">    2987 </span>            : #else
<span class="lineNum">    2988 </span><span class="lineNoCov">          0 :             void do_run()</span>
<span class="lineNum">    2989 </span>            :             {
<span class="lineNum">    2990 </span>            :                 try
<span class="lineNum">    2991 </span>            :                 {
<span class="lineNum">    2992 </span><span class="lineNoCov">          0 :                   f();</span>
<span class="lineNum">    2993 </span>            : #endif
<span class="lineNum">    2994 </span><span class="lineNoCov">          0 :                   this-&gt;mark_finished_with_result();</span>
<span class="lineNum">    2995 </span>            :                 }
<span class="lineNum">    2996 </span><span class="lineNoCov">          0 :                 catch(...)</span>
<span class="lineNum">    2997 </span>            :                 {
<span class="lineNum">    2998 </span><span class="lineNoCov">          0 :                     this-&gt;mark_exceptional_finish();</span>
<span class="lineNum">    2999 </span>            :                 }
<span class="lineNum">    3000 </span><span class="lineNoCov">          0 :             }</span>
<span class="lineNum">    3001 </span>            :         };
<span class="lineNum">    3002 </span>            :     }
<span class="lineNum">    3003 </span>            : 
<span class="lineNum">    3004 </span>            : #if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK
<span class="lineNum">    3005 </span>            :   #if defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
<span class="lineNum">    3006 </span>            :     template&lt;typename R, typename ...ArgTypes&gt;
<span class="lineNum">    3007 </span>            :     class packaged_task&lt;R(ArgTypes...)&gt;
<span class="lineNum">    3008 </span>            :     {
<span class="lineNum">    3009 </span>            :       typedef boost::shared_ptr&lt;detail::task_base_shared_state&lt;R(ArgTypes...)&gt; &gt; task_ptr;
<span class="lineNum">    3010 </span>            :       boost::shared_ptr&lt;detail::task_base_shared_state&lt;R(ArgTypes...)&gt; &gt; task;
<span class="lineNum">    3011 </span>            :   #else
<span class="lineNum">    3012 </span>            :     template&lt;typename R&gt;
<span class="lineNum">    3013 </span>            :     class packaged_task&lt;R()&gt;
<span class="lineNum">    3014 </span>            :     {
<span class="lineNum">    3015 </span>            :       typedef boost::shared_ptr&lt;detail::task_base_shared_state&lt;R()&gt; &gt; task_ptr;
<span class="lineNum">    3016 </span>            :       boost::shared_ptr&lt;detail::task_base_shared_state&lt;R()&gt; &gt; task;
<span class="lineNum">    3017 </span>            :   #endif
<span class="lineNum">    3018 </span>            : #else
<span class="lineNum">    3019 </span>            :     template&lt;typename R&gt;
<span class="lineNum">    3020 </span>            :     class packaged_task
<span class="lineNum">    3021 </span>            :     {
<span class="lineNum">    3022 </span>            :       typedef boost::shared_ptr&lt;detail::task_base_shared_state&lt;R&gt; &gt; task_ptr;
<span class="lineNum">    3023 </span>            :       boost::shared_ptr&lt;detail::task_base_shared_state&lt;R&gt; &gt; task;
<span class="lineNum">    3024 </span>            : #endif
<span class="lineNum">    3025 </span>            :         bool future_obtained;
<span class="lineNum">    3026 </span>            :         struct dummy;
<span class="lineNum">    3027 </span>            : 
<span class="lineNum">    3028 </span>            :     public:
<span class="lineNum">    3029 </span>            :         typedef R result_type;
<span class="lineNum">    3030 </span>            :         BOOST_THREAD_MOVABLE_ONLY(packaged_task)
<span class="lineNum">    3031 </span>            : 
<span class="lineNum">    3032 </span>            :         packaged_task():
<span class="lineNum">    3033 </span>            :             future_obtained(false)
<span class="lineNum">    3034 </span>            :         {}
<span class="lineNum">    3035 </span>            : 
<span class="lineNum">    3036 </span>            :         // construction and destruction
<span class="lineNum">    3037 </span>            : #if defined(BOOST_THREAD_RVALUE_REFERENCES_DONT_MATCH_FUNTION_PTR)
<span class="lineNum">    3038 </span>            : 
<span class="lineNum">    3039 </span>            : #if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK
<span class="lineNum">    3040 </span>            :   #if defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
<span class="lineNum">    3041 </span>            :         explicit packaged_task(R(*f)(), BOOST_THREAD_FWD_REF(ArgTypes)... args)
<span class="lineNum">    3042 </span>            :         {
<span class="lineNum">    3043 </span>            :             typedef R(*FR)(BOOST_THREAD_FWD_REF(ArgTypes)...);
<span class="lineNum">    3044 </span>            :             typedef detail::task_shared_state&lt;FR,R(ArgTypes...)&gt; task_shared_state_type;
<span class="lineNum">    3045 </span>            :             task= task_ptr(new task_shared_state_type(f, boost::move(args)...));
<span class="lineNum">    3046 </span>            :             future_obtained=false;
<span class="lineNum">    3047 </span>            :         }
<span class="lineNum">    3048 </span>            :   #else
<span class="lineNum">    3049 </span>            :         explicit packaged_task(R(*f)())
<span class="lineNum">    3050 </span>            :         {
<span class="lineNum">    3051 </span>            :             typedef R(*FR)();
<span class="lineNum">    3052 </span>            :             typedef detail::task_shared_state&lt;FR,R()&gt; task_shared_state_type;
<span class="lineNum">    3053 </span>            :             task= task_ptr(new task_shared_state_type(f));
<span class="lineNum">    3054 </span>            :             future_obtained=false;
<span class="lineNum">    3055 </span>            :         }
<span class="lineNum">    3056 </span>            :   #endif
<span class="lineNum">    3057 </span>            : #else
<span class="lineNum">    3058 </span>            :         explicit packaged_task(R(*f)())
<span class="lineNum">    3059 </span>            :         {
<span class="lineNum">    3060 </span>            :               typedef R(*FR)();
<span class="lineNum">    3061 </span>            :             typedef detail::task_shared_state&lt;FR,R&gt; task_shared_state_type;
<span class="lineNum">    3062 </span>            :             task= task_ptr(new task_shared_state_type(f));
<span class="lineNum">    3063 </span>            :             future_obtained=false;
<span class="lineNum">    3064 </span>            :         }
<span class="lineNum">    3065 </span>            : #endif
<span class="lineNum">    3066 </span>            : #endif
<span class="lineNum">    3067 </span>            : #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
<span class="lineNum">    3068 </span>            :         template &lt;class F&gt;
<span class="lineNum">    3069 </span>            :         explicit packaged_task(BOOST_THREAD_FWD_REF(F) f
<span class="lineNum">    3070 </span>            :             , typename boost::disable_if&lt;is_same&lt;typename decay&lt;F&gt;::type, packaged_task&gt;, dummy* &gt;::type=0
<span class="lineNum">    3071 </span>            :             )
<span class="lineNum">    3072 </span>            :         {
<span class="lineNum">    3073 </span>            :           typedef typename decay&lt;F&gt;::type FR;
<span class="lineNum">    3074 </span>            : #if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK
<span class="lineNum">    3075 </span>            :   #if defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
<span class="lineNum">    3076 </span>            :             typedef detail::task_shared_state&lt;FR,R(ArgTypes...)&gt; task_shared_state_type;
<span class="lineNum">    3077 </span>            :   #else
<span class="lineNum">    3078 </span>            :             typedef detail::task_shared_state&lt;FR,R()&gt; task_shared_state_type;
<span class="lineNum">    3079 </span>            :   #endif
<span class="lineNum">    3080 </span>            : #else
<span class="lineNum">    3081 </span>            :             typedef detail::task_shared_state&lt;FR,R&gt; task_shared_state_type;
<span class="lineNum">    3082 </span>            : #endif
<span class="lineNum">    3083 </span>            :             task = task_ptr(new task_shared_state_type(boost::forward&lt;F&gt;(f)));
<span class="lineNum">    3084 </span>            :             future_obtained = false;
<span class="lineNum">    3085 </span>            : 
<span class="lineNum">    3086 </span>            :         }
<span class="lineNum">    3087 </span>            : 
<span class="lineNum">    3088 </span>            : #else
<span class="lineNum">    3089 </span>            :         template &lt;class F&gt;
<span class="lineNum">    3090 </span>            :         explicit packaged_task(F const&amp; f
<span class="lineNum">    3091 </span>            :             , typename boost::disable_if&lt;is_same&lt;typename decay&lt;F&gt;::type, packaged_task&gt;, dummy* &gt;::type=0
<span class="lineNum">    3092 </span>            :             )
<span class="lineNum">    3093 </span>            :         {
<span class="lineNum">    3094 </span>            : #if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK
<span class="lineNum">    3095 </span>            :   #if defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
<span class="lineNum">    3096 </span>            :             typedef detail::task_shared_state&lt;F,R(ArgTypes...)&gt; task_shared_state_type;
<span class="lineNum">    3097 </span>            :   #else
<span class="lineNum">    3098 </span>            :             typedef detail::task_shared_state&lt;F,R()&gt; task_shared_state_type;
<span class="lineNum">    3099 </span>            :   #endif
<span class="lineNum">    3100 </span>            : #else
<span class="lineNum">    3101 </span>            :             typedef detail::task_shared_state&lt;F,R&gt; task_shared_state_type;
<span class="lineNum">    3102 </span>            : #endif
<span class="lineNum">    3103 </span>            :             task = task_ptr(new task_shared_state_type(f));
<span class="lineNum">    3104 </span>            :             future_obtained=false;
<span class="lineNum">    3105 </span>            :         }
<span class="lineNum">    3106 </span>            :         template &lt;class F&gt;
<span class="lineNum">    3107 </span>            :         explicit packaged_task(BOOST_THREAD_RV_REF(F) f)
<span class="lineNum">    3108 </span>            :         {
<span class="lineNum">    3109 </span>            : #if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK
<span class="lineNum">    3110 </span>            : #if defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
<span class="lineNum">    3111 </span>            :             typedef detail::task_shared_state&lt;F,R(ArgTypes...)&gt; task_shared_state_type;
<span class="lineNum">    3112 </span>            :             task = task_ptr(new task_shared_state_type(boost::move(f)));
<span class="lineNum">    3113 </span>            : #else
<span class="lineNum">    3114 </span>            :             typedef detail::task_shared_state&lt;F,R()&gt; task_shared_state_type;
<span class="lineNum">    3115 </span>            :             task = task_ptr(new task_shared_state_type(boost::move(f)));
<span class="lineNum">    3116 </span>            : #endif
<span class="lineNum">    3117 </span>            : #else
<span class="lineNum">    3118 </span>            :             typedef detail::task_shared_state&lt;F,R&gt; task_shared_state_type;
<span class="lineNum">    3119 </span>            :             task = task_ptr(new task_shared_state_type(boost::move(f)));
<span class="lineNum">    3120 </span>            : #endif
<span class="lineNum">    3121 </span>            :             future_obtained=false;
<span class="lineNum">    3122 </span>            : 
<span class="lineNum">    3123 </span>            :         }
<span class="lineNum">    3124 </span>            : #endif
<span class="lineNum">    3125 </span>            : 
<span class="lineNum">    3126 </span>            : #if defined BOOST_THREAD_PROVIDES_FUTURE_CTOR_ALLOCATORS
<span class="lineNum">    3127 </span>            : #if defined(BOOST_THREAD_RVALUE_REFERENCES_DONT_MATCH_FUNTION_PTR)
<span class="lineNum">    3128 </span>            :         template &lt;class Allocator&gt;
<span class="lineNum">    3129 </span>            :         packaged_task(boost::allocator_arg_t, Allocator a, R(*f)())
<span class="lineNum">    3130 </span>            :         {
<span class="lineNum">    3131 </span>            :           typedef R(*FR)();
<span class="lineNum">    3132 </span>            : #if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK
<span class="lineNum">    3133 </span>            :   #if defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
<span class="lineNum">    3134 </span>            :           typedef detail::task_shared_state&lt;FR,R(ArgTypes...)&gt; task_shared_state_type;
<span class="lineNum">    3135 </span>            :   #else
<span class="lineNum">    3136 </span>            :           typedef detail::task_shared_state&lt;FR,R()&gt; task_shared_state_type;
<span class="lineNum">    3137 </span>            :   #endif
<span class="lineNum">    3138 </span>            : #else
<span class="lineNum">    3139 </span>            :           typedef detail::task_shared_state&lt;FR,R&gt; task_shared_state_type;
<span class="lineNum">    3140 </span>            : #endif
<span class="lineNum">    3141 </span>            :           typedef typename Allocator::template rebind&lt;task_shared_state_type&gt;::other A2;
<span class="lineNum">    3142 </span>            :           A2 a2(a);
<span class="lineNum">    3143 </span>            :           typedef thread_detail::allocator_destructor&lt;A2&gt; D;
<span class="lineNum">    3144 </span>            : 
<span class="lineNum">    3145 </span>            :           task = task_ptr(::new(a2.allocate(1)) task_shared_state_type(f), D(a2, 1) );
<span class="lineNum">    3146 </span>            :           future_obtained = false;
<span class="lineNum">    3147 </span>            :         }
<span class="lineNum">    3148 </span>            : #endif // BOOST_THREAD_RVALUE_REFERENCES_DONT_MATCH_FUNTION_PTR
<span class="lineNum">    3149 </span>            : 
<span class="lineNum">    3150 </span>            : #if ! defined BOOST_NO_CXX11_RVALUE_REFERENCES
<span class="lineNum">    3151 </span>            :         template &lt;class F, class Allocator&gt;
<span class="lineNum">    3152 </span>            :         packaged_task(boost::allocator_arg_t, Allocator a, BOOST_THREAD_FWD_REF(F) f)
<span class="lineNum">    3153 </span>            :         {
<span class="lineNum">    3154 </span>            :           typedef typename decay&lt;F&gt;::type FR;
<span class="lineNum">    3155 </span>            : 
<span class="lineNum">    3156 </span>            : #if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK
<span class="lineNum">    3157 </span>            :   #if defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
<span class="lineNum">    3158 </span>            :           typedef detail::task_shared_state&lt;FR,R(ArgTypes...)&gt; task_shared_state_type;
<span class="lineNum">    3159 </span>            :   #else
<span class="lineNum">    3160 </span>            :           typedef detail::task_shared_state&lt;FR,R()&gt; task_shared_state_type;
<span class="lineNum">    3161 </span>            :   #endif
<span class="lineNum">    3162 </span>            : #else
<span class="lineNum">    3163 </span>            :           typedef detail::task_shared_state&lt;FR,R&gt; task_shared_state_type;
<span class="lineNum">    3164 </span>            : #endif
<span class="lineNum">    3165 </span>            :           typedef typename Allocator::template rebind&lt;task_shared_state_type&gt;::other A2;
<span class="lineNum">    3166 </span>            :           A2 a2(a);
<span class="lineNum">    3167 </span>            :           typedef thread_detail::allocator_destructor&lt;A2&gt; D;
<span class="lineNum">    3168 </span>            : 
<span class="lineNum">    3169 </span>            :           task = task_ptr(::new(a2.allocate(1)) task_shared_state_type(boost::forward&lt;F&gt;(f)), D(a2, 1) );
<span class="lineNum">    3170 </span>            :           future_obtained = false;
<span class="lineNum">    3171 </span>            :         }
<span class="lineNum">    3172 </span>            : #else // ! defined BOOST_NO_CXX11_RVALUE_REFERENCES
<span class="lineNum">    3173 </span>            :         template &lt;class F, class Allocator&gt;
<span class="lineNum">    3174 </span>            :         packaged_task(boost::allocator_arg_t, Allocator a, const F&amp; f)
<span class="lineNum">    3175 </span>            :         {
<span class="lineNum">    3176 </span>            : #if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK
<span class="lineNum">    3177 </span>            :   #if defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
<span class="lineNum">    3178 </span>            :           typedef detail::task_shared_state&lt;F,R(ArgTypes...)&gt; task_shared_state_type;
<span class="lineNum">    3179 </span>            :   #else
<span class="lineNum">    3180 </span>            :           typedef detail::task_shared_state&lt;F,R()&gt; task_shared_state_type;
<span class="lineNum">    3181 </span>            :   #endif
<span class="lineNum">    3182 </span>            : #else
<span class="lineNum">    3183 </span>            :           typedef detail::task_shared_state&lt;F,R&gt; task_shared_state_type;
<span class="lineNum">    3184 </span>            : #endif
<span class="lineNum">    3185 </span>            :           typedef typename Allocator::template rebind&lt;task_shared_state_type&gt;::other A2;
<span class="lineNum">    3186 </span>            :           A2 a2(a);
<span class="lineNum">    3187 </span>            :           typedef thread_detail::allocator_destructor&lt;A2&gt; D;
<span class="lineNum">    3188 </span>            : 
<span class="lineNum">    3189 </span>            :           task = task_ptr(::new(a2.allocate(1)) task_shared_state_type(f), D(a2, 1) );
<span class="lineNum">    3190 </span>            :           future_obtained = false;
<span class="lineNum">    3191 </span>            :         }
<span class="lineNum">    3192 </span>            :         template &lt;class F, class Allocator&gt;
<span class="lineNum">    3193 </span>            :         packaged_task(boost::allocator_arg_t, Allocator a, BOOST_THREAD_RV_REF(F) f)
<span class="lineNum">    3194 </span>            :         {
<span class="lineNum">    3195 </span>            : #if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK
<span class="lineNum">    3196 </span>            :   #if defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
<span class="lineNum">    3197 </span>            :           typedef detail::task_shared_state&lt;F,R(ArgTypes...)&gt; task_shared_state_type;
<span class="lineNum">    3198 </span>            :   #else
<span class="lineNum">    3199 </span>            :           typedef detail::task_shared_state&lt;F,R()&gt; task_shared_state_type;
<span class="lineNum">    3200 </span>            :   #endif
<span class="lineNum">    3201 </span>            : #else
<span class="lineNum">    3202 </span>            :           typedef detail::task_shared_state&lt;F,R&gt; task_shared_state_type;
<span class="lineNum">    3203 </span>            : #endif
<span class="lineNum">    3204 </span>            :           typedef typename Allocator::template rebind&lt;task_shared_state_type&gt;::other A2;
<span class="lineNum">    3205 </span>            :           A2 a2(a);
<span class="lineNum">    3206 </span>            :           typedef thread_detail::allocator_destructor&lt;A2&gt; D;
<span class="lineNum">    3207 </span>            : 
<span class="lineNum">    3208 </span>            :           task = task_ptr(::new(a2.allocate(1)) task_shared_state_type(boost::move(f)), D(a2, 1) );
<span class="lineNum">    3209 </span>            :           future_obtained = false;
<span class="lineNum">    3210 </span>            :         }
<span class="lineNum">    3211 </span>            : 
<span class="lineNum">    3212 </span>            : #endif //BOOST_NO_CXX11_RVALUE_REFERENCES
<span class="lineNum">    3213 </span>            : #endif // BOOST_THREAD_PROVIDES_FUTURE_CTOR_ALLOCATORS
<span class="lineNum">    3214 </span>            : 
<span class="lineNum">    3215 </span>            :         ~packaged_task() {
<span class="lineNum">    3216 </span>            :             if(task) {
<span class="lineNum">    3217 </span>            :                 task-&gt;owner_destroyed();
<span class="lineNum">    3218 </span>            :             }
<span class="lineNum">    3219 </span>            :         }
<span class="lineNum">    3220 </span>            : 
<span class="lineNum">    3221 </span>            :         // assignment
<span class="lineNum">    3222 </span>            :         packaged_task(BOOST_THREAD_RV_REF(packaged_task) other) BOOST_NOEXCEPT
<span class="lineNum">    3223 </span>            :         : future_obtained(BOOST_THREAD_RV(other).future_obtained) {
<span class="lineNum">    3224 </span>            :             task.swap(BOOST_THREAD_RV(other).task);
<span class="lineNum">    3225 </span>            :             BOOST_THREAD_RV(other).future_obtained=false;
<span class="lineNum">    3226 </span>            :         }
<span class="lineNum">    3227 </span>            :         packaged_task&amp; operator=(BOOST_THREAD_RV_REF(packaged_task) other) BOOST_NOEXCEPT {
<span class="lineNum">    3228 </span>            : 
<span class="lineNum">    3229 </span>            : #if ! defined  BOOST_NO_CXX11_RVALUE_REFERENCES
<span class="lineNum">    3230 </span>            :             packaged_task temp(boost::move(other));
<span class="lineNum">    3231 </span>            : #else
<span class="lineNum">    3232 </span>            :             packaged_task temp(static_cast&lt;BOOST_THREAD_RV_REF(packaged_task)&gt;(other));
<span class="lineNum">    3233 </span>            : #endif
<span class="lineNum">    3234 </span>            :             swap(temp);
<span class="lineNum">    3235 </span>            :             return *this;
<span class="lineNum">    3236 </span>            :         }
<span class="lineNum">    3237 </span>            : 
<span class="lineNum">    3238 </span>            :         void reset() {
<span class="lineNum">    3239 </span>            :             if (!valid())
<span class="lineNum">    3240 </span>            :                 throw future_error(system::make_error_code(future_errc::no_state));
<span class="lineNum">    3241 </span>            : 
<span class="lineNum">    3242 </span>            :             // As if *this = packaged_task(task-&gt;callable());
<span class="lineNum">    3243 </span>            : 
<span class="lineNum">    3244 </span>            :             task-&gt;reset();
<span class="lineNum">    3245 </span>            :             future_obtained=false;
<span class="lineNum">    3246 </span>            :         }
<span class="lineNum">    3247 </span>            : 
<span class="lineNum">    3248 </span>            :         void swap(packaged_task&amp; other) BOOST_NOEXCEPT {
<span class="lineNum">    3249 </span>            :             task.swap(other.task);
<span class="lineNum">    3250 </span>            :             std::swap(future_obtained,other.future_obtained);
<span class="lineNum">    3251 </span>            :         }
<span class="lineNum">    3252 </span>            :         bool valid() const BOOST_NOEXCEPT {
<span class="lineNum">    3253 </span>            :           return task.get()!=0;
<span class="lineNum">    3254 </span>            :         }
<span class="lineNum">    3255 </span>            : 
<span class="lineNum">    3256 </span>            :         // result retrieval
<span class="lineNum">    3257 </span>            :         BOOST_THREAD_FUTURE&lt;R&gt; get_future() {
<span class="lineNum">    3258 </span>            :             if(!task) {
<span class="lineNum">    3259 </span>            :                 boost::throw_exception(task_moved());
<span class="lineNum">    3260 </span>            :             } else if(!future_obtained) {
<span class="lineNum">    3261 </span>            :                 future_obtained=true;
<span class="lineNum">    3262 </span>            :                 return BOOST_THREAD_FUTURE&lt;R&gt;(task);
<span class="lineNum">    3263 </span>            :             } else {
<span class="lineNum">    3264 </span>            :                 boost::throw_exception(future_already_retrieved());
<span class="lineNum">    3265 </span>            :             }
<span class="lineNum">    3266 </span>            :         }
<span class="lineNum">    3267 </span>            : 
<span class="lineNum">    3268 </span>            :         // execution
<span class="lineNum">    3269 </span>            : #if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK &amp;&amp; defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
<span class="lineNum">    3270 </span>            :         void operator()(BOOST_THREAD_RV_REF(ArgTypes)... args) {
<span class="lineNum">    3271 </span>            :             if(!task) {
<span class="lineNum">    3272 </span>            :                 boost::throw_exception(task_moved());
<span class="lineNum">    3273 </span>            :             }
<span class="lineNum">    3274 </span>            :             task-&gt;run(boost::move(args)...);
<span class="lineNum">    3275 </span>            :         }
<span class="lineNum">    3276 </span>            :         void make_ready_at_thread_exit(ArgTypes... args) {
<span class="lineNum">    3277 </span>            :           if(!task) {
<span class="lineNum">    3278 </span>            :               boost::throw_exception(task_moved());
<span class="lineNum">    3279 </span>            :           }
<span class="lineNum">    3280 </span>            :           if (task-&gt;has_value()) {
<span class="lineNum">    3281 </span>            :                 boost::throw_exception(promise_already_satisfied());
<span class="lineNum">    3282 </span>            :           }
<span class="lineNum">    3283 </span>            :           task-&gt;apply(boost::move(args)...);
<span class="lineNum">    3284 </span>            :         }
<span class="lineNum">    3285 </span>            : #else
<span class="lineNum">    3286 </span>            :         void operator()() {
<span class="lineNum">    3287 </span>            :             if(!task) {
<span class="lineNum">    3288 </span>            :                 boost::throw_exception(task_moved());
<span class="lineNum">    3289 </span>            :             }
<span class="lineNum">    3290 </span>            :             task-&gt;run();
<span class="lineNum">    3291 </span>            :         }
<span class="lineNum">    3292 </span>            :         void make_ready_at_thread_exit() {
<span class="lineNum">    3293 </span>            :           if(!task) {
<span class="lineNum">    3294 </span>            :               boost::throw_exception(task_moved());
<span class="lineNum">    3295 </span>            :           }
<span class="lineNum">    3296 </span>            :           if (task-&gt;has_value()) boost::throw_exception(promise_already_satisfied());
<span class="lineNum">    3297 </span>            :           task-&gt;apply();
<span class="lineNum">    3298 </span>            :         }
<span class="lineNum">    3299 </span>            : #endif
<span class="lineNum">    3300 </span>            :         template&lt;typename F&gt;
<span class="lineNum">    3301 </span>            :         void set_wait_callback(F f) {
<span class="lineNum">    3302 </span>            :             task-&gt;set_wait_callback(f,this);
<span class="lineNum">    3303 </span>            :         }
<span class="lineNum">    3304 </span>            :     };
<span class="lineNum">    3305 </span>            : }
<span class="lineNum">    3306 </span>            : #if defined BOOST_THREAD_PROVIDES_FUTURE_CTOR_ALLOCATORS
<span class="lineNum">    3307 </span>            : namespace boost { namespace container {
<span class="lineNum">    3308 </span>            :     template &lt;class R, class Alloc&gt;
<span class="lineNum">    3309 </span>            :     struct uses_allocator&lt; ::boost::packaged_task&lt;R&gt; , Alloc&gt; : true_type
<span class="lineNum">    3310 </span>            :     {};
<span class="lineNum">    3311 </span>            : }}
<span class="lineNum">    3312 </span>            : #if ! defined  BOOST_NO_CXX11_ALLOCATOR
<span class="lineNum">    3313 </span>            : namespace std {
<span class="lineNum">    3314 </span>            :     template &lt;class R, class Alloc&gt;
<span class="lineNum">    3315 </span>            :     struct uses_allocator&lt; ::boost::packaged_task&lt;R&gt; , Alloc&gt; : true_type
<span class="lineNum">    3316 </span>            :     {};
<span class="lineNum">    3317 </span>            : }
<span class="lineNum">    3318 </span>            : #endif
<span class="lineNum">    3319 </span>            : #endif
<span class="lineNum">    3320 </span>            : 
<span class="lineNum">    3321 </span>            : namespace boost
<span class="lineNum">    3322 </span>            : {
<span class="lineNum">    3323 </span>            :   BOOST_THREAD_DCL_MOVABLE_BEG(T) packaged_task&lt;T&gt; BOOST_THREAD_DCL_MOVABLE_END
<span class="lineNum">    3324 </span>            : 
<span class="lineNum">    3325 </span>            : namespace detail
<span class="lineNum">    3326 </span>            : {
<span class="lineNum">    3327 </span>            :   ////////////////////////////////
<span class="lineNum">    3328 </span>            :   // make_future_deferred_shared_state
<span class="lineNum">    3329 </span>            :   ////////////////////////////////
<span class="lineNum">    3330 </span>            :   template &lt;class Rp, class Fp&gt;
<span class="lineNum">    3331 </span>            :   BOOST_THREAD_FUTURE&lt;Rp&gt;
<span class="lineNum">    3332 </span>            :   make_future_deferred_shared_state(BOOST_THREAD_FWD_REF(Fp) f) {
<span class="lineNum">    3333 </span>            :     shared_ptr&lt;future_deferred_shared_state&lt;Rp, Fp&gt; &gt;
<span class="lineNum">    3334 </span>            :         h(new future_deferred_shared_state&lt;Rp, Fp&gt;(boost::forward&lt;Fp&gt;(f)));
<span class="lineNum">    3335 </span>            :     return BOOST_THREAD_FUTURE&lt;Rp&gt;(h);
<span class="lineNum">    3336 </span>            :   }
<span class="lineNum">    3337 </span>            : 
<span class="lineNum">    3338 </span>            :   ////////////////////////////////
<span class="lineNum">    3339 </span>            :   // make_future_async_shared_state
<span class="lineNum">    3340 </span>            :   ////////////////////////////////
<span class="lineNum">    3341 </span>            :   template &lt;class Rp, class Fp&gt;
<span class="lineNum">    3342 </span>            :   BOOST_THREAD_FUTURE&lt;Rp&gt;
<span class="lineNum">    3343 </span>            :   make_future_async_shared_state(BOOST_THREAD_FWD_REF(Fp) f) {
<span class="lineNum">    3344 </span>            :     shared_ptr&lt;future_async_shared_state&lt;Rp, Fp&gt; &gt;
<span class="lineNum">    3345 </span>            :         h(new future_async_shared_state&lt;Rp, Fp&gt;());
<span class="lineNum">    3346 </span>            :     h-&gt;init(boost::forward&lt;Fp&gt;(f));
<span class="lineNum">    3347 </span>            :     return BOOST_THREAD_FUTURE&lt;Rp&gt;(h);
<span class="lineNum">    3348 </span>            :   }
<span class="lineNum">    3349 </span>            : }
<span class="lineNum">    3350 </span>            : 
<span class="lineNum">    3351 </span>            :     ////////////////////////////////
<span class="lineNum">    3352 </span>            :     // template &lt;class F, class... ArgTypes&gt;
<span class="lineNum">    3353 </span>            :     // future&lt;R&gt; async(launch policy, F&amp;&amp;, ArgTypes&amp;&amp;...);
<span class="lineNum">    3354 </span>            :     ////////////////////////////////
<span class="lineNum">    3355 </span>            : 
<span class="lineNum">    3356 </span>            : #if defined BOOST_THREAD_RVALUE_REFERENCES_DONT_MATCH_FUNTION_PTR
<span class="lineNum">    3357 </span>            : 
<span class="lineNum">    3358 </span>            : #if defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
<span class="lineNum">    3359 </span>            :   template &lt;class R, class... ArgTypes&gt;
<span class="lineNum">    3360 </span>            :   BOOST_THREAD_FUTURE&lt;R&gt;
<span class="lineNum">    3361 </span>            :   async(launch policy, R(*f)(BOOST_THREAD_FWD_REF(ArgTypes)...), BOOST_THREAD_FWD_REF(ArgTypes)... args) {
<span class="lineNum">    3362 </span>            :     typedef R(*F)(BOOST_THREAD_FWD_REF(ArgTypes)...);
<span class="lineNum">    3363 </span>            :     typedef detail::invoker&lt;typename decay&lt;F&gt;::type, typename decay&lt;ArgTypes&gt;::type...&gt; BF;
<span class="lineNum">    3364 </span>            :     typedef typename BF::result_type Rp;
<span class="lineNum">    3365 </span>            : 
<span class="lineNum">    3366 </span>            :     if (underlying_cast&lt;int&gt;(policy) &amp; int(launch::async)) {
<span class="lineNum">    3367 </span>            :       return BOOST_THREAD_MAKE_RV_REF(boost::detail::make_future_async_shared_state&lt;Rp&gt;(
<span class="lineNum">    3368 </span>            :               BF(
<span class="lineNum">    3369 </span>            :                   f
<span class="lineNum">    3370 </span>            :                   , thread_detail::decay_copy(boost::forward&lt;ArgTypes&gt;(args))...
<span class="lineNum">    3371 </span>            :               )
<span class="lineNum">    3372 </span>            :           ));
<span class="lineNum">    3373 </span>            :     } else if (underlying_cast&lt;int&gt;(policy) &amp; int(launch::deferred)) {
<span class="lineNum">    3374 </span>            :       return BOOST_THREAD_MAKE_RV_REF(boost::detail::make_future_deferred_shared_state&lt;Rp&gt;(
<span class="lineNum">    3375 </span>            :               BF(
<span class="lineNum">    3376 </span>            :                   f
<span class="lineNum">    3377 </span>            :                   , thread_detail::decay_copy(boost::forward&lt;ArgTypes&gt;(args))...
<span class="lineNum">    3378 </span>            :               )
<span class="lineNum">    3379 </span>            :           ));
<span class="lineNum">    3380 </span>            :     } else {
<span class="lineNum">    3381 </span>            :       std::terminate();
<span class="lineNum">    3382 </span>            :       BOOST_THREAD_FUTURE&lt;R&gt; ret;
<span class="lineNum">    3383 </span>            :       return ::boost::move(ret);
<span class="lineNum">    3384 </span>            :     }
<span class="lineNum">    3385 </span>            :   }
<span class="lineNum">    3386 </span>            : 
<span class="lineNum">    3387 </span>            : #else // defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
<span class="lineNum">    3388 </span>            : 
<span class="lineNum">    3389 </span>            :   template &lt;class R&gt;
<span class="lineNum">    3390 </span>            :   BOOST_THREAD_FUTURE&lt;R&gt;
<span class="lineNum">    3391 </span>            :   async(launch policy, R(*f)()) {
<span class="lineNum">    3392 </span>            :   #if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK
<span class="lineNum">    3393 </span>            :     typedef packaged_task&lt;R()&gt; packaged_task_type;
<span class="lineNum">    3394 </span>            :   #else
<span class="lineNum">    3395 </span>            :     typedef packaged_task&lt;R&gt; packaged_task_type;
<span class="lineNum">    3396 </span>            :   #endif
<span class="lineNum">    3397 </span>            : 
<span class="lineNum">    3398 </span>            :     if (underlying_cast&lt;int&gt;(policy) &amp; int(launch::async)) {
<span class="lineNum">    3399 </span>            :       packaged_task_type pt( f );
<span class="lineNum">    3400 </span>            :       BOOST_THREAD_FUTURE&lt;R&gt; ret = BOOST_THREAD_MAKE_RV_REF(pt.get_future());
<span class="lineNum">    3401 </span>            :       ret.set_async();
<span class="lineNum">    3402 </span>            :       boost::thread( boost::move(pt) ).detach();
<span class="lineNum">    3403 </span>            :       return ::boost::move(ret);
<span class="lineNum">    3404 </span>            :     } else if (underlying_cast&lt;int&gt;(policy) &amp; int(launch::deferred)) {
<span class="lineNum">    3405 </span>            :       std::terminate();
<span class="lineNum">    3406 </span>            :       BOOST_THREAD_FUTURE&lt;R&gt; ret;
<span class="lineNum">    3407 </span>            :       return ::boost::move(ret);
<span class="lineNum">    3408 </span>            :     } else {
<span class="lineNum">    3409 </span>            :       std::terminate();
<span class="lineNum">    3410 </span>            :       BOOST_THREAD_FUTURE&lt;R&gt; ret;
<span class="lineNum">    3411 </span>            :       return ::boost::move(ret);
<span class="lineNum">    3412 </span>            :     }
<span class="lineNum">    3413 </span>            :   }
<span class="lineNum">    3414 </span>            : #endif
<span class="lineNum">    3415 </span>            : #endif // defined(BOOST_THREAD_RVALUE_REFERENCES_DONT_MATCH_FUNTION_PTR)
<span class="lineNum">    3416 </span>            : 
<span class="lineNum">    3417 </span>            : #if defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
<span class="lineNum">    3418 </span>            : 
<span class="lineNum">    3419 </span>            :   template &lt;class F, class ...ArgTypes&gt;
<span class="lineNum">    3420 </span>            :   BOOST_THREAD_FUTURE&lt;typename boost::result_of&lt;typename decay&lt;F&gt;::type(
<span class="lineNum">    3421 </span>            :       typename decay&lt;ArgTypes&gt;::type...
<span class="lineNum">    3422 </span>            :   )&gt;::type&gt;
<span class="lineNum">    3423 </span>            :   async(launch policy, BOOST_THREAD_FWD_REF(F) f, BOOST_THREAD_FWD_REF(ArgTypes)... args) {
<span class="lineNum">    3424 </span>            :     typedef typename boost::result_of&lt;typename decay&lt;F&gt;::type(
<span class="lineNum">    3425 </span>            :         typename decay&lt;ArgTypes&gt;::type...
<span class="lineNum">    3426 </span>            :     )&gt;::type R;
<span class="lineNum">    3427 </span>            :     typedef detail::invoker&lt;typename decay&lt;F&gt;::type, typename decay&lt;ArgTypes&gt;::type...&gt; BF;
<span class="lineNum">    3428 </span>            :     typedef typename BF::result_type Rp;
<span class="lineNum">    3429 </span>            : 
<span class="lineNum">    3430 </span>            :     if (underlying_cast&lt;int&gt;(policy) &amp; int(launch::async)) {
<span class="lineNum">    3431 </span>            :       return BOOST_THREAD_MAKE_RV_REF(boost::detail::make_future_async_shared_state&lt;Rp&gt;(
<span class="lineNum">    3432 </span>            :               BF(
<span class="lineNum">    3433 </span>            :                   thread_detail::decay_copy(boost::forward&lt;F&gt;(f))
<span class="lineNum">    3434 </span>            :                 , thread_detail::decay_copy(boost::forward&lt;ArgTypes&gt;(args))...
<span class="lineNum">    3435 </span>            :               )
<span class="lineNum">    3436 </span>            :           ));
<span class="lineNum">    3437 </span>            :     } else if (underlying_cast&lt;int&gt;(policy) &amp; int(launch::deferred)) {
<span class="lineNum">    3438 </span>            :       return BOOST_THREAD_MAKE_RV_REF(boost::detail::make_future_deferred_shared_state&lt;Rp&gt;(
<span class="lineNum">    3439 </span>            :               BF(
<span class="lineNum">    3440 </span>            :                   thread_detail::decay_copy(boost::forward&lt;F&gt;(f))
<span class="lineNum">    3441 </span>            :                 , thread_detail::decay_copy(boost::forward&lt;ArgTypes&gt;(args))...
<span class="lineNum">    3442 </span>            :               )
<span class="lineNum">    3443 </span>            :           ));
<span class="lineNum">    3444 </span>            :     } else {
<span class="lineNum">    3445 </span>            :       std::terminate();
<span class="lineNum">    3446 </span>            :       BOOST_THREAD_FUTURE&lt;R&gt; ret;
<span class="lineNum">    3447 </span>            :       return ::boost::move(ret);
<span class="lineNum">    3448 </span>            :     }
<span class="lineNum">    3449 </span>            :   }
<span class="lineNum">    3450 </span>            : 
<span class="lineNum">    3451 </span>            : #else // defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
<span class="lineNum">    3452 </span>            : 
<span class="lineNum">    3453 </span>            :   template &lt;class F&gt;
<span class="lineNum">    3454 </span>            :   BOOST_THREAD_FUTURE&lt;typename boost::result_of&lt;typename decay&lt;F&gt;::type()&gt;::type&gt;
<span class="lineNum">    3455 </span>            :   async(launch policy, BOOST_THREAD_FWD_REF(F) f) {
<span class="lineNum">    3456 </span>            :     typedef typename boost::result_of&lt;typename decay&lt;F&gt;::type()&gt;::type R;
<span class="lineNum">    3457 </span>            : #if defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK
<span class="lineNum">    3458 </span>            :     typedef packaged_task&lt;R()&gt; packaged_task_type;
<span class="lineNum">    3459 </span>            : #else // defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK
<span class="lineNum">    3460 </span>            :     typedef packaged_task&lt;R&gt; packaged_task_type;
<span class="lineNum">    3461 </span>            : #endif // defined BOOST_THREAD_PROVIDES_SIGNATURE_PACKAGED_TASK
<span class="lineNum">    3462 </span>            : 
<span class="lineNum">    3463 </span>            :     if (underlying_cast&lt;int&gt;(policy) &amp; int(launch::async)) {
<span class="lineNum">    3464 </span>            :       packaged_task_type pt( boost::forward&lt;F&gt;(f) );
<span class="lineNum">    3465 </span>            :       BOOST_THREAD_FUTURE&lt;R&gt; ret = pt.get_future();
<span class="lineNum">    3466 </span>            :       ret.set_async();
<span class="lineNum">    3467 </span>            :       boost::thread( boost::move(pt) ).detach();
<span class="lineNum">    3468 </span>            :       return ::boost::move(ret);
<span class="lineNum">    3469 </span>            :     } else if (underlying_cast&lt;int&gt;(policy) &amp; int(launch::deferred)) {
<span class="lineNum">    3470 </span>            :       std::terminate();
<span class="lineNum">    3471 </span>            :       BOOST_THREAD_FUTURE&lt;R&gt; ret;
<span class="lineNum">    3472 </span>            :       return ::boost::move(ret);
<span class="lineNum">    3473 </span>            :       //          return boost::detail::make_future_deferred_shared_state&lt;Rp&gt;(
<span class="lineNum">    3474 </span>            :       //              BF(
<span class="lineNum">    3475 </span>            :       //                  thread_detail::decay_copy(boost::forward&lt;F&gt;(f))
<span class="lineNum">    3476 </span>            :       //              )
<span class="lineNum">    3477 </span>            :       //          );
<span class="lineNum">    3478 </span>            :     } else {
<span class="lineNum">    3479 </span>            :       std::terminate();
<span class="lineNum">    3480 </span>            :       BOOST_THREAD_FUTURE&lt;R&gt; ret;
<span class="lineNum">    3481 </span>            :       return ::boost::move(ret);
<span class="lineNum">    3482 </span>            :     }
<span class="lineNum">    3483 </span>            :   }
<span class="lineNum">    3484 </span>            : #endif // defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
<span class="lineNum">    3485 </span>            : 
<span class="lineNum">    3486 </span>            : #ifdef BOOST_THREAD_PROVIDES_EXECUTORS
<span class="lineNum">    3487 </span>            : namespace detail {
<span class="lineNum">    3488 </span>            :     /////////////////////////
<span class="lineNum">    3489 </span>            :     /// shared_state_nullary_task
<span class="lineNum">    3490 </span>            :     /////////////////////////
<span class="lineNum">    3491 </span>            :     template&lt;typename Rp, typename Fp&gt;
<span class="lineNum">    3492 </span>            :     struct shared_state_nullary_task
<span class="lineNum">    3493 </span>            :     {
<span class="lineNum">    3494 </span>            :       shared_state&lt;Rp&gt;* that;
<span class="lineNum">    3495 </span>            :       Fp f_;
<span class="lineNum">    3496 </span>            :     public:
<span class="lineNum">    3497 </span>            : 
<span class="lineNum">    3498 </span>            :       shared_state_nullary_task(shared_state&lt;Rp&gt;* st, BOOST_THREAD_FWD_REF(Fp) f)
<span class="lineNum">    3499 </span>            :       : that(st), f_(boost::move(f))
<span class="lineNum">    3500 </span>            :       {};
<span class="lineNum">    3501 </span>            : #if ! defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
<span class="lineNum">    3502 </span>            :       BOOST_THREAD_COPYABLE_AND_MOVABLE(shared_state_nullary_task)
<span class="lineNum">    3503 </span>            :       shared_state_nullary_task(shared_state_nullary_task const&amp; x) //BOOST_NOEXCEPT
<span class="lineNum">    3504 </span>            :       : that(x.that), f_(x.f_)
<span class="lineNum">    3505 </span>            :       {}
<span class="lineNum">    3506 </span>            :       shared_state_nullary_task&amp; operator=(BOOST_THREAD_COPY_ASSIGN_REF(shared_state_nullary_task) x) //BOOST_NOEXCEPT
<span class="lineNum">    3507 </span>            :       {
<span class="lineNum">    3508 </span>            :         if (this != &amp;x) {
<span class="lineNum">    3509 </span>            :           that=x.that;
<span class="lineNum">    3510 </span>            :           f_=x.f_;
<span class="lineNum">    3511 </span>            :         }
<span class="lineNum">    3512 </span>            :         return *this;
<span class="lineNum">    3513 </span>            :       }
<span class="lineNum">    3514 </span>            :       // move
<span class="lineNum">    3515 </span>            :       shared_state_nullary_task(BOOST_THREAD_RV_REF(shared_state_nullary_task) x) //BOOST_NOEXCEPT
<span class="lineNum">    3516 </span>            :       : that(x.that), f_(boost::move(x.f_))
<span class="lineNum">    3517 </span>            :       {
<span class="lineNum">    3518 </span>            :         x.that=0;
<span class="lineNum">    3519 </span>            :       }
<span class="lineNum">    3520 </span>            :       shared_state_nullary_task&amp; operator=(BOOST_THREAD_RV_REF(shared_state_nullary_task) x) //BOOST_NOEXCEPT
<span class="lineNum">    3521 </span>            :       {
<span class="lineNum">    3522 </span>            :         if (this != &amp;x) {
<span class="lineNum">    3523 </span>            :           that=x.that;
<span class="lineNum">    3524 </span>            :           f_=boost::move(x.f_);
<span class="lineNum">    3525 </span>            :           x.that=0;
<span class="lineNum">    3526 </span>            :         }
<span class="lineNum">    3527 </span>            :         return *this;
<span class="lineNum">    3528 </span>            :       }
<span class="lineNum">    3529 </span>            : #endif
<span class="lineNum">    3530 </span>            :       void operator()() {
<span class="lineNum">    3531 </span>            :         try {
<span class="lineNum">    3532 </span>            :           that-&gt;mark_finished_with_result(f_());
<span class="lineNum">    3533 </span>            :         } catch(...) {
<span class="lineNum">    3534 </span>            :           that-&gt;mark_exceptional_finish();
<span class="lineNum">    3535 </span>            :         }
<span class="lineNum">    3536 </span>            :       }
<span class="lineNum">    3537 </span>            :     };
<span class="lineNum">    3538 </span>            : 
<span class="lineNum">    3539 </span>            :     template&lt;typename Fp&gt;
<span class="lineNum">    3540 </span>            :     struct shared_state_nullary_task&lt;void, Fp&gt;
<span class="lineNum">    3541 </span>            :     {
<span class="lineNum">    3542 </span>            :       shared_state&lt;void&gt;* that;
<span class="lineNum">    3543 </span>            :       Fp f_;
<span class="lineNum">    3544 </span>            :     public:
<span class="lineNum">    3545 </span>            :       shared_state_nullary_task(shared_state&lt;void&gt;* st, BOOST_THREAD_FWD_REF(Fp) f)
<span class="lineNum">    3546 </span>            :       : that(st), f_(boost::move(f))
<span class="lineNum">    3547 </span>            :       {};
<span class="lineNum">    3548 </span>            : #if ! defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
<span class="lineNum">    3549 </span>            :       BOOST_THREAD_COPYABLE_AND_MOVABLE(shared_state_nullary_task)
<span class="lineNum">    3550 </span>            :       shared_state_nullary_task(shared_state_nullary_task const&amp; x) //BOOST_NOEXCEPT
<span class="lineNum">    3551 </span>            :       : that(x.that), f_(x.f_)
<span class="lineNum">    3552 </span>            :       {}
<span class="lineNum">    3553 </span>            :       shared_state_nullary_task&amp; operator=(BOOST_THREAD_COPY_ASSIGN_REF(shared_state_nullary_task) x) //BOOST_NOEXCEPT
<span class="lineNum">    3554 </span>            :       {
<span class="lineNum">    3555 </span>            :         if (this != &amp;x) {
<span class="lineNum">    3556 </span>            :           that=x.that;
<span class="lineNum">    3557 </span>            :           f_=x.f_;
<span class="lineNum">    3558 </span>            :         }
<span class="lineNum">    3559 </span>            :         return *this;
<span class="lineNum">    3560 </span>            :       }
<span class="lineNum">    3561 </span>            :       // move
<span class="lineNum">    3562 </span>            :       shared_state_nullary_task(BOOST_THREAD_RV_REF(shared_state_nullary_task) x) BOOST_NOEXCEPT
<span class="lineNum">    3563 </span>            :       : that(x.that), f_(boost::move(x.f_))
<span class="lineNum">    3564 </span>            :       {
<span class="lineNum">    3565 </span>            :         x.that=0;
<span class="lineNum">    3566 </span>            :       }
<span class="lineNum">    3567 </span>            :       shared_state_nullary_task&amp; operator=(BOOST_THREAD_RV_REF(shared_state_nullary_task) x) BOOST_NOEXCEPT {
<span class="lineNum">    3568 </span>            :         if (this != &amp;x) {
<span class="lineNum">    3569 </span>            :           that=x.that;
<span class="lineNum">    3570 </span>            :           f_=boost::move(x.f_);
<span class="lineNum">    3571 </span>            :           x.that=0;
<span class="lineNum">    3572 </span>            :         }
<span class="lineNum">    3573 </span>            :         return *this;
<span class="lineNum">    3574 </span>            :       }
<span class="lineNum">    3575 </span>            : #endif
<span class="lineNum">    3576 </span>            :       void operator()() {
<span class="lineNum">    3577 </span>            :         try {
<span class="lineNum">    3578 </span>            :           f_();
<span class="lineNum">    3579 </span>            :           that-&gt;mark_finished_with_result();
<span class="lineNum">    3580 </span>            :         } catch(...) {
<span class="lineNum">    3581 </span>            :           that-&gt;mark_exceptional_finish();
<span class="lineNum">    3582 </span>            :         }
<span class="lineNum">    3583 </span>            :       }
<span class="lineNum">    3584 </span>            :     };
<span class="lineNum">    3585 </span>            : 
<span class="lineNum">    3586 </span>            :     template&lt;typename Rp, typename Fp&gt;
<span class="lineNum">    3587 </span>            :     struct shared_state_nullary_task&lt;Rp&amp;, Fp&gt;
<span class="lineNum">    3588 </span>            :     {
<span class="lineNum">    3589 </span>            :       shared_state&lt;Rp&amp;&gt;* that;
<span class="lineNum">    3590 </span>            :       Fp f_;
<span class="lineNum">    3591 </span>            :     public:
<span class="lineNum">    3592 </span>            :       shared_state_nullary_task(shared_state&lt;Rp&amp;&gt;* st, BOOST_THREAD_FWD_REF(Fp) f)
<span class="lineNum">    3593 </span>            :         : that(st), f_(boost::move(f))
<span class="lineNum">    3594 </span>            :       {}
<span class="lineNum">    3595 </span>            : #if ! defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
<span class="lineNum">    3596 </span>            :       BOOST_THREAD_COPYABLE_AND_MOVABLE(shared_state_nullary_task)
<span class="lineNum">    3597 </span>            :       shared_state_nullary_task(shared_state_nullary_task const&amp; x) BOOST_NOEXCEPT
<span class="lineNum">    3598 </span>            :       : that(x.that), f_(x.f_) {}
<span class="lineNum">    3599 </span>            : 
<span class="lineNum">    3600 </span>            :       shared_state_nullary_task&amp; operator=(BOOST_THREAD_COPY_ASSIGN_REF(shared_state_nullary_task) x) BOOST_NOEXCEPT {
<span class="lineNum">    3601 </span>            :         if (this != &amp;x){
<span class="lineNum">    3602 </span>            :           that=x.that;
<span class="lineNum">    3603 </span>            :           f_=x.f_;
<span class="lineNum">    3604 </span>            :         }
<span class="lineNum">    3605 </span>            :         return *this;
<span class="lineNum">    3606 </span>            :       }
<span class="lineNum">    3607 </span>            :       // move
<span class="lineNum">    3608 </span>            :       shared_state_nullary_task(BOOST_THREAD_RV_REF(shared_state_nullary_task) x) BOOST_NOEXCEPT
<span class="lineNum">    3609 </span>            :       : that(x.that), f_(boost::move(x.f_))
<span class="lineNum">    3610 </span>            :       {
<span class="lineNum">    3611 </span>            :         x.that=0;
<span class="lineNum">    3612 </span>            :       }
<span class="lineNum">    3613 </span>            :       shared_state_nullary_task&amp; operator=(BOOST_THREAD_RV_REF(shared_state_nullary_task) x) BOOST_NOEXCEPT {
<span class="lineNum">    3614 </span>            :         if (this != &amp;x) {
<span class="lineNum">    3615 </span>            :           that=x.that;
<span class="lineNum">    3616 </span>            :           f_=boost::move(x.f_);
<span class="lineNum">    3617 </span>            :           x.that=0;
<span class="lineNum">    3618 </span>            :         }
<span class="lineNum">    3619 </span>            :         return *this;
<span class="lineNum">    3620 </span>            :       }
<span class="lineNum">    3621 </span>            : #endif
<span class="lineNum">    3622 </span>            :       void operator()() {
<span class="lineNum">    3623 </span>            :         try {
<span class="lineNum">    3624 </span>            :           that-&gt;mark_finished_with_result(f_());
<span class="lineNum">    3625 </span>            :         } catch(...) {
<span class="lineNum">    3626 </span>            :           that-&gt;mark_exceptional_finish();
<span class="lineNum">    3627 </span>            :         }
<span class="lineNum">    3628 </span>            :       }
<span class="lineNum">    3629 </span>            :     };
<span class="lineNum">    3630 </span>            : 
<span class="lineNum">    3631 </span>            :     /////////////////////////
<span class="lineNum">    3632 </span>            :     /// future_executor_shared_state_base
<span class="lineNum">    3633 </span>            :     /////////////////////////
<span class="lineNum">    3634 </span>            :     template&lt;typename Rp, typename Executor&gt;
<span class="lineNum">    3635 </span>            :     struct future_executor_shared_state: shared_state&lt;Rp&gt;
<span class="lineNum">    3636 </span>            :     {
<span class="lineNum">    3637 </span>            :       typedef shared_state&lt;Rp&gt; base_type;
<span class="lineNum">    3638 </span>            :     protected:
<span class="lineNum">    3639 </span>            :     public:
<span class="lineNum">    3640 </span>            :       template&lt;typename Fp&gt;
<span class="lineNum">    3641 </span>            :       future_executor_shared_state(Executor&amp; ex, BOOST_THREAD_FWD_REF(Fp) f) {
<span class="lineNum">    3642 </span>            :         this-&gt;set_executor();
<span class="lineNum">    3643 </span>            :         shared_state_nullary_task&lt;Rp,Fp&gt; t(this, boost::forward&lt;Fp&gt;(f));
<span class="lineNum">    3644 </span>            :         ex.submit(boost::move(t));
<span class="lineNum">    3645 </span>            :       }
<span class="lineNum">    3646 </span>            : 
<span class="lineNum">    3647 </span>            :       virtual void block_if_needed(boost::unique_lock&lt;boost::mutex&gt;&amp;lk)
<span class="lineNum">    3648 </span>            :       {
<span class="lineNum">    3649 </span>            :         this-&gt;wait(lk, false);
<span class="lineNum">    3650 </span>            :       }
<span class="lineNum">    3651 </span>            : 
<span class="lineNum">    3652 </span>            :       ~future_executor_shared_state() {}
<span class="lineNum">    3653 </span>            :     };
<span class="lineNum">    3654 </span>            : 
<span class="lineNum">    3655 </span>            :     ////////////////////////////////
<span class="lineNum">    3656 </span>            :     // make_future_executor_shared_state
<span class="lineNum">    3657 </span>            :     ////////////////////////////////
<span class="lineNum">    3658 </span>            :     template &lt;class Rp, class Fp, class Executor&gt;
<span class="lineNum">    3659 </span>            :     BOOST_THREAD_FUTURE&lt;Rp&gt;
<span class="lineNum">    3660 </span>            :     make_future_executor_shared_state(Executor&amp; ex, BOOST_THREAD_FWD_REF(Fp) f) {
<span class="lineNum">    3661 </span>            :       shared_ptr&lt;future_executor_shared_state&lt;Rp, Executor&gt; &gt;
<span class="lineNum">    3662 </span>            :           h(new future_executor_shared_state&lt;Rp, Executor&gt;(ex, boost::forward&lt;Fp&gt;(f)));
<span class="lineNum">    3663 </span>            :       return BOOST_THREAD_FUTURE&lt;Rp&gt;(h);
<span class="lineNum">    3664 </span>            :     }
<span class="lineNum">    3665 </span>            : 
<span class="lineNum">    3666 </span>            : } // detail
<span class="lineNum">    3667 </span>            : 
<span class="lineNum">    3668 </span>            :     ////////////////////////////////
<span class="lineNum">    3669 </span>            :     // template &lt;class Executor, class F, class... ArgTypes&gt;
<span class="lineNum">    3670 </span>            :     // future&lt;R&gt; async(Executor&amp; ex, F&amp;&amp;, ArgTypes&amp;&amp;...);
<span class="lineNum">    3671 </span>            :     ////////////////////////////////
<span class="lineNum">    3672 </span>            : 
<span class="lineNum">    3673 </span>            : //#if ! defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
<span class="lineNum">    3674 </span>            : #if defined(BOOST_THREAD_PROVIDES_INVOKE) &amp;&amp; ! defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) &amp;&amp; ! defined(BOOST_NO_CXX11_HDR_TUPLE)
<span class="lineNum">    3675 </span>            : 
<span class="lineNum">    3676 </span>            : #if defined BOOST_THREAD_RVALUE_REFERENCES_DONT_MATCH_FUNTION_PTR
<span class="lineNum">    3677 </span>            : 
<span class="lineNum">    3678 </span>            :   template &lt;class Executor, class R, class... ArgTypes&gt;
<span class="lineNum">    3679 </span>            :   BOOST_THREAD_FUTURE&lt;R&gt;
<span class="lineNum">    3680 </span>            :   async(Executor&amp; ex, R(*f)(BOOST_THREAD_FWD_REF(ArgTypes)...), BOOST_THREAD_FWD_REF(ArgTypes)... args) {
<span class="lineNum">    3681 </span>            :     typedef R(*F)(BOOST_THREAD_FWD_REF(ArgTypes)...);
<span class="lineNum">    3682 </span>            :     typedef detail::invoker&lt;typename decay&lt;F&gt;::type, typename decay&lt;ArgTypes&gt;::type...&gt; BF;
<span class="lineNum">    3683 </span>            :     typedef typename BF::result_type Rp;
<span class="lineNum">    3684 </span>            : 
<span class="lineNum">    3685 </span>            :     return BOOST_THREAD_MAKE_RV_REF(boost::detail::make_future_executor_shared_state&lt;Rp&gt;(ex,
<span class="lineNum">    3686 </span>            :         BF(
<span class="lineNum">    3687 </span>            :             f
<span class="lineNum">    3688 </span>            :             , thread_detail::decay_copy(boost::forward&lt;ArgTypes&gt;(args))...
<span class="lineNum">    3689 </span>            :         )
<span class="lineNum">    3690 </span>            :     ));
<span class="lineNum">    3691 </span>            :   }
<span class="lineNum">    3692 </span>            : #endif // defined BOOST_THREAD_RVALUE_REFERENCES_DONT_MATCH_FUNTION_PTR
<span class="lineNum">    3693 </span>            : 
<span class="lineNum">    3694 </span>            :   template &lt;class Executor, class F, class ...ArgTypes&gt;
<span class="lineNum">    3695 </span>            :   BOOST_THREAD_FUTURE&lt;typename boost::result_of&lt;typename decay&lt;F&gt;::type(
<span class="lineNum">    3696 </span>            :       typename decay&lt;ArgTypes&gt;::type...
<span class="lineNum">    3697 </span>            :   )&gt;::type&gt;
<span class="lineNum">    3698 </span>            :   async(Executor&amp; ex, BOOST_THREAD_FWD_REF(F) f, BOOST_THREAD_FWD_REF(ArgTypes)... args) {
<span class="lineNum">    3699 </span>            :     typedef detail::invoker&lt;typename decay&lt;F&gt;::type, typename decay&lt;ArgTypes&gt;::type...&gt; BF;
<span class="lineNum">    3700 </span>            :     typedef typename BF::result_type Rp;
<span class="lineNum">    3701 </span>            : 
<span class="lineNum">    3702 </span>            :     return BOOST_THREAD_MAKE_RV_REF(boost::detail::make_future_executor_shared_state&lt;Rp&gt;(ex,
<span class="lineNum">    3703 </span>            :         BF(
<span class="lineNum">    3704 </span>            :             thread_detail::decay_copy(boost::forward&lt;F&gt;(f))
<span class="lineNum">    3705 </span>            :             , thread_detail::decay_copy(boost::forward&lt;ArgTypes&gt;(args))...
<span class="lineNum">    3706 </span>            :         )
<span class="lineNum">    3707 </span>            :     ));
<span class="lineNum">    3708 </span>            :   }
<span class="lineNum">    3709 </span>            : 
<span class="lineNum">    3710 </span>            : #else // ! defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
<span class="lineNum">    3711 </span>            : #if defined BOOST_THREAD_RVALUE_REFERENCES_DONT_MATCH_FUNTION_PTR
<span class="lineNum">    3712 </span>            : 
<span class="lineNum">    3713 </span>            :   template &lt;class Executor, class R&gt;
<span class="lineNum">    3714 </span>            :   BOOST_THREAD_FUTURE&lt;R&gt;
<span class="lineNum">    3715 </span>            :   async(Executor&amp; ex, R(*f)()) {
<span class="lineNum">    3716 </span>            :     typedef R(*F)();
<span class="lineNum">    3717 </span>            :     typedef detail::invoker&lt;F&gt; BF;
<span class="lineNum">    3718 </span>            :     typedef typename BF::result_type Rp;
<span class="lineNum">    3719 </span>            : 
<span class="lineNum">    3720 </span>            :     return BOOST_THREAD_MAKE_RV_REF(boost::detail::make_future_executor_shared_state&lt;Rp&gt;(ex,
<span class="lineNum">    3721 </span>            :         BF(
<span class="lineNum">    3722 </span>            :             f
<span class="lineNum">    3723 </span>            :         )
<span class="lineNum">    3724 </span>            :     ));
<span class="lineNum">    3725 </span>            :   }
<span class="lineNum">    3726 </span>            : 
<span class="lineNum">    3727 </span>            :   template &lt;class Executor, class R, class A1&gt;
<span class="lineNum">    3728 </span>            :   BOOST_THREAD_FUTURE&lt;R&gt;
<span class="lineNum">    3729 </span>            :   async(Executor&amp; ex, R(*f)(BOOST_THREAD_FWD_REF(A1)), BOOST_THREAD_FWD_REF(A1) a1) {
<span class="lineNum">    3730 </span>            :     typedef R(*F)(BOOST_THREAD_FWD_REF(A1));
<span class="lineNum">    3731 </span>            :     typedef detail::invoker&lt;F, typename decay&lt;A1&gt;::type&gt; BF;
<span class="lineNum">    3732 </span>            :     typedef typename BF::result_type Rp;
<span class="lineNum">    3733 </span>            : 
<span class="lineNum">    3734 </span>            :     return BOOST_THREAD_MAKE_RV_REF(boost::detail::make_future_executor_shared_state&lt;Rp&gt;(ex,
<span class="lineNum">    3735 </span>            :         BF(
<span class="lineNum">    3736 </span>            :             f
<span class="lineNum">    3737 </span>            :             , thread_detail::decay_copy(boost::forward&lt;A1&gt;(a1))
<span class="lineNum">    3738 </span>            :         )
<span class="lineNum">    3739 </span>            :     ));
<span class="lineNum">    3740 </span>            :   }
<span class="lineNum">    3741 </span>            : #endif // defined BOOST_THREAD_RVALUE_REFERENCES_DONT_MATCH_FUNTION_PTR
<span class="lineNum">    3742 </span>            : 
<span class="lineNum">    3743 </span>            :   template &lt;class Executor, class F&gt;
<span class="lineNum">    3744 </span>            :   BOOST_THREAD_FUTURE&lt;typename boost::result_of&lt;typename decay&lt;F&gt;::type()&gt;::type&gt;
<span class="lineNum">    3745 </span>            :   async(Executor&amp; ex, BOOST_THREAD_FWD_REF(F) f)  {
<span class="lineNum">    3746 </span>            :     typedef detail::invoker&lt;typename decay&lt;F&gt;::type&gt; BF;
<span class="lineNum">    3747 </span>            :     typedef typename BF::result_type Rp;
<span class="lineNum">    3748 </span>            : 
<span class="lineNum">    3749 </span>            :     return boost::detail::make_future_executor_shared_state&lt;Rp&gt;(ex,
<span class="lineNum">    3750 </span>            :         BF(
<span class="lineNum">    3751 </span>            :             thread_detail::decay_copy(boost::forward&lt;F&gt;(f))
<span class="lineNum">    3752 </span>            :         )
<span class="lineNum">    3753 </span>            :     );
<span class="lineNum">    3754 </span>            :   }
<span class="lineNum">    3755 </span>            : 
<span class="lineNum">    3756 </span>            :   template &lt;class Executor, class F, class A1&gt;
<span class="lineNum">    3757 </span>            :   BOOST_THREAD_FUTURE&lt;typename boost::result_of&lt;typename decay&lt;F&gt;::type(
<span class="lineNum">    3758 </span>            :       typename decay&lt;A1&gt;::type
<span class="lineNum">    3759 </span>            :   )&gt;::type&gt;
<span class="lineNum">    3760 </span>            :   async(Executor&amp; ex, BOOST_THREAD_FWD_REF(F) f, BOOST_THREAD_FWD_REF(A1) a1) {
<span class="lineNum">    3761 </span>            :     typedef detail::invoker&lt;typename decay&lt;F&gt;::type, typename decay&lt;A1&gt;::type&gt; BF;
<span class="lineNum">    3762 </span>            :     typedef typename BF::result_type Rp;
<span class="lineNum">    3763 </span>            : 
<span class="lineNum">    3764 </span>            :     return BOOST_THREAD_MAKE_RV_REF(boost::detail::make_future_executor_shared_state&lt;Rp&gt;(ex,
<span class="lineNum">    3765 </span>            :         BF(
<span class="lineNum">    3766 </span>            :             thread_detail::decay_copy(boost::forward&lt;F&gt;(f))
<span class="lineNum">    3767 </span>            :           , thread_detail::decay_copy(boost::forward&lt;A1&gt;(a1))
<span class="lineNum">    3768 </span>            :         )
<span class="lineNum">    3769 </span>            :     ));
<span class="lineNum">    3770 </span>            :   }
<span class="lineNum">    3771 </span>            : 
<span class="lineNum">    3772 </span>            :   template &lt;class Executor, class F, class A1, class A2&gt;
<span class="lineNum">    3773 </span>            :   BOOST_THREAD_FUTURE&lt;typename boost::result_of&lt;typename decay&lt;F&gt;::type(
<span class="lineNum">    3774 </span>            :       typename decay&lt;A1&gt;::type, typename decay&lt;A2&gt;::type
<span class="lineNum">    3775 </span>            :   )&gt;::type&gt;
<span class="lineNum">    3776 </span>            :   async(Executor&amp; ex, BOOST_THREAD_FWD_REF(F) f, BOOST_THREAD_FWD_REF(A1) a1, BOOST_THREAD_FWD_REF(A2) a2) {
<span class="lineNum">    3777 </span>            :     typedef detail::invoker&lt;typename decay&lt;F&gt;::type, typename decay&lt;A1&gt;::type, typename decay&lt;A2&gt;::type&gt; BF;
<span class="lineNum">    3778 </span>            :     typedef typename BF::result_type Rp;
<span class="lineNum">    3779 </span>            : 
<span class="lineNum">    3780 </span>            :     return BOOST_THREAD_MAKE_RV_REF(boost::detail::make_future_executor_shared_state&lt;Rp&gt;(ex,
<span class="lineNum">    3781 </span>            :         BF(
<span class="lineNum">    3782 </span>            :             thread_detail::decay_copy(boost::forward&lt;F&gt;(f))
<span class="lineNum">    3783 </span>            :           , thread_detail::decay_copy(boost::forward&lt;A1&gt;(a1))
<span class="lineNum">    3784 </span>            :           , thread_detail::decay_copy(boost::forward&lt;A2&gt;(a2))
<span class="lineNum">    3785 </span>            :         )
<span class="lineNum">    3786 </span>            :     ));
<span class="lineNum">    3787 </span>            :   }
<span class="lineNum">    3788 </span>            : 
<span class="lineNum">    3789 </span>            : #endif //! defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
<span class="lineNum">    3790 </span>            : #endif
<span class="lineNum">    3791 </span>            : 
<span class="lineNum">    3792 </span>            :   ////////////////////////////////
<span class="lineNum">    3793 </span>            :   // template &lt;class F, class... ArgTypes&gt;
<span class="lineNum">    3794 </span>            :   // future&lt;R&gt; async(F&amp;&amp;, ArgTypes&amp;&amp;...);
<span class="lineNum">    3795 </span>            :   ////////////////////////////////
<span class="lineNum">    3796 </span>            : 
<span class="lineNum">    3797 </span>            : #if defined BOOST_THREAD_RVALUE_REFERENCES_DONT_MATCH_FUNTION_PTR
<span class="lineNum">    3798 </span>            :   #if defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
<span class="lineNum">    3799 </span>            :   template &lt;class R, class... ArgTypes&gt;
<span class="lineNum">    3800 </span>            :   BOOST_THREAD_FUTURE&lt;R&gt;
<span class="lineNum">    3801 </span>            :   async(R(*f)(BOOST_THREAD_FWD_REF(ArgTypes)...), BOOST_THREAD_FWD_REF(ArgTypes)... args) {
<span class="lineNum">    3802 </span>            :     return BOOST_THREAD_MAKE_RV_REF(async(launch(launch::any), f, boost::forward&lt;ArgTypes&gt;(args)...));
<span class="lineNum">    3803 </span>            :   }
<span class="lineNum">    3804 </span>            :   #else
<span class="lineNum">    3805 </span>            :   template &lt;class R&gt;
<span class="lineNum">    3806 </span>            :   BOOST_THREAD_FUTURE&lt;R&gt;
<span class="lineNum">    3807 </span>            :   async(R(*f)()) {
<span class="lineNum">    3808 </span>            :     return BOOST_THREAD_MAKE_RV_REF(async(launch(launch::any), f));
<span class="lineNum">    3809 </span>            :   }
<span class="lineNum">    3810 </span>            :   #endif
<span class="lineNum">    3811 </span>            : #endif
<span class="lineNum">    3812 </span>            : 
<span class="lineNum">    3813 </span>            : #if defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD)
<span class="lineNum">    3814 </span>            :   template &lt;class F, class ...ArgTypes&gt;
<span class="lineNum">    3815 </span>            :   BOOST_THREAD_FUTURE&lt;typename boost::result_of&lt;typename decay&lt;F&gt;::type(
<span class="lineNum">    3816 </span>            :       typename decay&lt;ArgTypes&gt;::type...
<span class="lineNum">    3817 </span>            :   )&gt;::type&gt;
<span class="lineNum">    3818 </span>            :   async(BOOST_THREAD_FWD_REF(F) f, BOOST_THREAD_FWD_REF(ArgTypes)... args) {
<span class="lineNum">    3819 </span>            :       return BOOST_THREAD_MAKE_RV_REF(async(launch(launch::any), boost::forward&lt;F&gt;(f), boost::forward&lt;ArgTypes&gt;(args)...));
<span class="lineNum">    3820 </span>            :   }
<span class="lineNum">    3821 </span>            : #else
<span class="lineNum">    3822 </span>            :   template &lt;class F&gt;
<span class="lineNum">    3823 </span>            :   BOOST_THREAD_FUTURE&lt;typename boost::result_of&lt;F()&gt;::type&gt;
<span class="lineNum">    3824 </span>            :   async(BOOST_THREAD_FWD_REF(F) f) {
<span class="lineNum">    3825 </span>            :       return BOOST_THREAD_MAKE_RV_REF(async(launch(launch::any), boost::forward&lt;F&gt;(f)));
<span class="lineNum">    3826 </span>            :   }
<span class="lineNum">    3827 </span>            : #endif
<span class="lineNum">    3828 </span>            : 
<span class="lineNum">    3829 </span>            :   ////////////////////////////////
<span class="lineNum">    3830 </span>            :   // make_future deprecated
<span class="lineNum">    3831 </span>            :   ////////////////////////////////
<span class="lineNum">    3832 </span>            :   template &lt;typename T&gt;
<span class="lineNum">    3833 </span>            :   BOOST_THREAD_FUTURE&lt;typename decay&lt;T&gt;::type&gt; make_future(BOOST_THREAD_FWD_REF(T) value) {
<span class="lineNum">    3834 </span>            :     typedef typename decay&lt;T&gt;::type future_value_type;
<span class="lineNum">    3835 </span>            :     promise&lt;future_value_type&gt; p;
<span class="lineNum">    3836 </span>            :     p.set_value(boost::forward&lt;future_value_type&gt;(value));
<span class="lineNum">    3837 </span>            :     return BOOST_THREAD_MAKE_RV_REF(p.get_future());
<span class="lineNum">    3838 </span>            :   }
<span class="lineNum">    3839 </span>            : 
<span class="lineNum">    3840 </span>            : #if defined BOOST_THREAD_USES_MOVE
<span class="lineNum">    3841 </span>            :   inline BOOST_THREAD_FUTURE&lt;void&gt; make_future() {
<span class="lineNum">    3842 </span>            :     promise&lt;void&gt; p;
<span class="lineNum">    3843 </span>            :     p.set_value();
<span class="lineNum">    3844 </span>            :     return BOOST_THREAD_MAKE_RV_REF(p.get_future());
<span class="lineNum">    3845 </span>            :   }
<span class="lineNum">    3846 </span>            : #endif
<span class="lineNum">    3847 </span>            : 
<span class="lineNum">    3848 </span>            :   ////////////////////////////////
<span class="lineNum">    3849 </span>            :   // make_ready_future
<span class="lineNum">    3850 </span>            :   ////////////////////////////////
<span class="lineNum">    3851 </span>            :   namespace detail {
<span class="lineNum">    3852 </span>            :     template &lt;class T&gt;
<span class="lineNum">    3853 </span>            :     struct deduced_type_impl
<span class="lineNum">    3854 </span>            :     {
<span class="lineNum">    3855 </span>            :         typedef T type;
<span class="lineNum">    3856 </span>            :     };
<span class="lineNum">    3857 </span>            : 
<span class="lineNum">    3858 </span>            :     template &lt;class T&gt;
<span class="lineNum">    3859 </span>            :     struct deduced_type_impl&lt;reference_wrapper&lt;T&gt; const&gt;
<span class="lineNum">    3860 </span>            :     {
<span class="lineNum">    3861 </span>            :         typedef T&amp; type;
<span class="lineNum">    3862 </span>            :     };
<span class="lineNum">    3863 </span>            :     template &lt;class T&gt;
<span class="lineNum">    3864 </span>            :     struct deduced_type_impl&lt;reference_wrapper&lt;T&gt; &gt;
<span class="lineNum">    3865 </span>            :     {
<span class="lineNum">    3866 </span>            :         typedef T&amp; type;
<span class="lineNum">    3867 </span>            :     };
<span class="lineNum">    3868 </span>            : #if __cplusplus &gt; 201103L
<span class="lineNum">    3869 </span>            :     template &lt;class T&gt;
<span class="lineNum">    3870 </span>            :     struct deduced_type_impl&lt;std::reference_wrapper&lt;T&gt; &gt;
<span class="lineNum">    3871 </span>            :     {
<span class="lineNum">    3872 </span>            :         typedef T&amp; type;
<span class="lineNum">    3873 </span>            :     };
<span class="lineNum">    3874 </span>            : #endif
<span class="lineNum">    3875 </span>            :     template &lt;class T&gt;
<span class="lineNum">    3876 </span>            :     struct deduced_type
<span class="lineNum">    3877 </span>            :     {
<span class="lineNum">    3878 </span>            :         typedef typename detail::deduced_type_impl&lt;typename decay&lt;T&gt;::type&gt;::type type;
<span class="lineNum">    3879 </span>            :     };
<span class="lineNum">    3880 </span>            : 
<span class="lineNum">    3881 </span>            :   }
<span class="lineNum">    3882 </span>            : 
<span class="lineNum">    3883 </span>            : 
<span class="lineNum">    3884 </span>            : #if ! defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
<span class="lineNum">    3885 </span>            :   template &lt;int = 0, int..., class T&gt;
<span class="lineNum">    3886 </span>            : #else
<span class="lineNum">    3887 </span>            :   template &lt;class T&gt;
<span class="lineNum">    3888 </span>            : #endif
<span class="lineNum">    3889 </span>            :   BOOST_THREAD_FUTURE&lt;typename detail::deduced_type&lt;T&gt;::type&gt; make_ready_future(BOOST_THREAD_FWD_REF(T) value) {
<span class="lineNum">    3890 </span>            :     typedef typename detail::deduced_type&lt;T&gt;::type future_value_type;
<span class="lineNum">    3891 </span>            :     promise&lt;future_value_type&gt; p;
<span class="lineNum">    3892 </span>            :     p.set_value(boost::forward&lt;T&gt;(value));
<span class="lineNum">    3893 </span>            :     return BOOST_THREAD_MAKE_RV_REF(p.get_future());
<span class="lineNum">    3894 </span>            :   }
<span class="lineNum">    3895 </span>            : 
<span class="lineNum">    3896 </span>            :   // explicit overloads
<span class="lineNum">    3897 </span>            :   template &lt;class T&gt;
<span class="lineNum">    3898 </span>            :   BOOST_THREAD_FUTURE&lt;T&gt; make_ready_future(typename remove_reference&lt;T&gt;::type &amp; x)
<span class="lineNum">    3899 </span>            :   {
<span class="lineNum">    3900 </span>            :     promise&lt;T&gt; p;
<span class="lineNum">    3901 </span>            :     p.set_value(x);
<span class="lineNum">    3902 </span>            :     return p.get_future();
<span class="lineNum">    3903 </span>            :   }
<span class="lineNum">    3904 </span>            : 
<span class="lineNum">    3905 </span>            :   template &lt;class T&gt;
<span class="lineNum">    3906 </span>            :   BOOST_THREAD_FUTURE&lt;T&gt; make_ready_future(BOOST_THREAD_FWD_REF(typename remove_reference&lt;T&gt;::type) x)
<span class="lineNum">    3907 </span>            :   {
<span class="lineNum">    3908 </span>            :     promise&lt;T&gt; p;
<span class="lineNum">    3909 </span>            :     p.set_value(forward&lt;typename remove_reference&lt;T&gt;::type&gt;(x));
<span class="lineNum">    3910 </span>            :     return p.get_future();
<span class="lineNum">    3911 </span>            :   }
<span class="lineNum">    3912 </span>            : 
<span class="lineNum">    3913 </span>            :   // variadic overload
<span class="lineNum">    3914 </span>            : #if ! defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
<span class="lineNum">    3915 </span>            :   template &lt;class T, class ...Args&gt;
<span class="lineNum">    3916 </span>            :   BOOST_THREAD_FUTURE&lt;T&gt; make_ready_future(Args&amp;&amp;... args)
<span class="lineNum">    3917 </span>            :   {
<span class="lineNum">    3918 </span>            :     promise&lt;T&gt; p;
<span class="lineNum">    3919 </span>            :     p.emplace(forward&lt;Args&gt;(args)...);
<span class="lineNum">    3920 </span>            :     return p.get_future();
<span class="lineNum">    3921 </span>            : 
<span class="lineNum">    3922 </span>            :   }
<span class="lineNum">    3923 </span>            : #endif
<span class="lineNum">    3924 </span>            : 
<span class="lineNum">    3925 </span>            :   template &lt;typename T, typename T1&gt;
<span class="lineNum">    3926 </span>            :   BOOST_THREAD_FUTURE&lt;T&gt; make_ready_no_decay_future(T1 value) {
<span class="lineNum">    3927 </span>            :     typedef T future_value_type;
<span class="lineNum">    3928 </span>            :     promise&lt;future_value_type&gt; p;
<span class="lineNum">    3929 </span>            :     p.set_value(value);
<span class="lineNum">    3930 </span>            :     return BOOST_THREAD_MAKE_RV_REF(p.get_future());
<span class="lineNum">    3931 </span>            :   }
<span class="lineNum">    3932 </span>            : 
<span class="lineNum">    3933 </span>            : #if ! defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined BOOST_THREAD_USES_MOVE
<span class="lineNum">    3934 </span>            :   inline BOOST_THREAD_FUTURE&lt;void&gt; make_ready_future() {
<span class="lineNum">    3935 </span>            :     promise&lt;void&gt; p;
<span class="lineNum">    3936 </span>            :     p.set_value();
<span class="lineNum">    3937 </span>            :     return p.get_future();
<span class="lineNum">    3938 </span>            :   }
<span class="lineNum">    3939 </span>            : #endif
<span class="lineNum">    3940 </span>            : 
<span class="lineNum">    3941 </span>            :   template &lt;typename T&gt;
<span class="lineNum">    3942 </span>            :   BOOST_THREAD_FUTURE&lt;T&gt; make_ready_future(exception_ptr ex)  {
<span class="lineNum">    3943 </span>            :     promise&lt;T&gt; p;
<span class="lineNum">    3944 </span>            :     p.set_exception(ex);
<span class="lineNum">    3945 </span>            :     return BOOST_THREAD_MAKE_RV_REF(p.get_future());
<span class="lineNum">    3946 </span>            :   }
<span class="lineNum">    3947 </span>            : 
<span class="lineNum">    3948 </span>            :   template &lt;typename T&gt;
<span class="lineNum">    3949 </span>            :   BOOST_THREAD_FUTURE&lt;T&gt; make_exceptional_future(exception_ptr ex) {
<span class="lineNum">    3950 </span>            :     promise&lt;T&gt; p;
<span class="lineNum">    3951 </span>            :     p.set_exception(ex);
<span class="lineNum">    3952 </span>            :     return BOOST_THREAD_MAKE_RV_REF(p.get_future());
<span class="lineNum">    3953 </span>            :   }
<span class="lineNum">    3954 </span>            : 
<span class="lineNum">    3955 </span>            :   template &lt;typename T, typename E&gt;
<span class="lineNum">    3956 </span>            :   BOOST_THREAD_FUTURE&lt;T&gt; make_exceptional_future(E ex) {
<span class="lineNum">    3957 </span>            :     promise&lt;T&gt; p;
<span class="lineNum">    3958 </span>            :     p.set_exception(boost::copy_exception(ex));
<span class="lineNum">    3959 </span>            :     return BOOST_THREAD_MAKE_RV_REF(p.get_future());
<span class="lineNum">    3960 </span>            :   }
<span class="lineNum">    3961 </span>            : 
<span class="lineNum">    3962 </span>            :   template &lt;typename T&gt;
<span class="lineNum">    3963 </span>            :   BOOST_THREAD_FUTURE&lt;T&gt; make_exceptional_future() {
<span class="lineNum">    3964 </span>            :     promise&lt;T&gt; p;
<span class="lineNum">    3965 </span>            :     p.set_exception(boost::current_exception());
<span class="lineNum">    3966 </span>            :     return BOOST_THREAD_MAKE_RV_REF(p.get_future());
<span class="lineNum">    3967 </span>            :   }
<span class="lineNum">    3968 </span>            : 
<span class="lineNum">    3969 </span>            :   template &lt;typename T&gt;
<span class="lineNum">    3970 </span>            :   BOOST_THREAD_FUTURE&lt;T&gt; make_exceptional_future_if_invalid(BOOST_THREAD_FWD_REF(BOOST_THREAD_FUTURE&lt;T&gt;) fut) {
<span class="lineNum">    3971 </span>            :     fut.set_exceptional_if_invalid();
<span class="lineNum">    3972 </span>            :     return boost::move(fut);
<span class="lineNum">    3973 </span>            :   }
<span class="lineNum">    3974 </span>            :   template &lt;typename T&gt;
<span class="lineNum">    3975 </span>            :   shared_future&lt;T&gt; make_exceptional_future_if_invalid(shared_future&lt;T&gt; fut) {
<span class="lineNum">    3976 </span>            :     fut.set_exceptional_if_invalid();
<span class="lineNum">    3977 </span>            :     return fut;
<span class="lineNum">    3978 </span>            :   }
<span class="lineNum">    3979 </span>            : 
<span class="lineNum">    3980 </span>            : #if 0
<span class="lineNum">    3981 </span>            :   template&lt;typename CLOSURE&gt;
<span class="lineNum">    3982 </span>            :   make_future(CLOSURE closure) -&gt; BOOST_THREAD_FUTURE&lt;decltype(closure())&gt; {
<span class="lineNum">    3983 </span>            :       typedef decltype(closure()) T;
<span class="lineNum">    3984 </span>            :       promise&lt;T&gt; p;
<span class="lineNum">    3985 </span>            :       try {
<span class="lineNum">    3986 </span>            :         p.set_value(closure());
<span class="lineNum">    3987 </span>            :       } catch(...) {
<span class="lineNum">    3988 </span>            :         p.set_exception(std::current_exception());
<span class="lineNum">    3989 </span>            :       }
<span class="lineNum">    3990 </span>            :       return BOOST_THREAD_MAKE_RV_REF(p.get_future());
<span class="lineNum">    3991 </span>            :   }
<span class="lineNum">    3992 </span>            : #endif
<span class="lineNum">    3993 </span>            : 
<span class="lineNum">    3994 </span>            :   ////////////////////////////////
<span class="lineNum">    3995 </span>            :   // make_shared_future deprecated
<span class="lineNum">    3996 </span>            :   ////////////////////////////////
<span class="lineNum">    3997 </span>            :   template &lt;typename T&gt;
<span class="lineNum">    3998 </span>            :   shared_future&lt;typename decay&lt;T&gt;::type&gt; make_shared_future(BOOST_THREAD_FWD_REF(T) value) {
<span class="lineNum">    3999 </span>            :     typedef typename decay&lt;T&gt;::type future_type;
<span class="lineNum">    4000 </span>            :     promise&lt;future_type&gt; p;
<span class="lineNum">    4001 </span>            :     p.set_value(boost::forward&lt;T&gt;(value));
<span class="lineNum">    4002 </span>            :     return BOOST_THREAD_MAKE_RV_REF(p.get_future().share());
<span class="lineNum">    4003 </span>            :   }
<span class="lineNum">    4004 </span>            : 
<span class="lineNum">    4005 </span>            :   inline shared_future&lt;void&gt; make_shared_future()  {
<span class="lineNum">    4006 </span>            :     promise&lt;void&gt; p;
<span class="lineNum">    4007 </span>            :     return BOOST_THREAD_MAKE_RV_REF(p.get_future().share());
<span class="lineNum">    4008 </span>            :   }
<span class="lineNum">    4009 </span>            : 
<span class="lineNum">    4010 </span>            :   ////////////////////////////////
<span class="lineNum">    4011 </span>            :   // detail::future_async_continuation_shared_state
<span class="lineNum">    4012 </span>            :   ////////////////////////////////
<span class="lineNum">    4013 </span>            : #if defined BOOST_THREAD_PROVIDES_FUTURE_CONTINUATION
<span class="lineNum">    4014 </span>            : namespace detail
<span class="lineNum">    4015 </span>            : {
<span class="lineNum">    4016 </span>            : 
<span class="lineNum">    4017 </span>            :   /////////////////////////
<span class="lineNum">    4018 </span>            :   /// future_async_continuation_shared_state
<span class="lineNum">    4019 </span>            :   /////////////////////////
<span class="lineNum">    4020 </span>            : 
<span class="lineNum">    4021 </span>            :   template&lt;typename F, typename Rp, typename Fp&gt;
<span class="lineNum">    4022 </span>            :   struct future_async_continuation_shared_state: future_async_shared_state_base&lt;Rp&gt;
<span class="lineNum">    4023 </span>            :   {
<span class="lineNum">    4024 </span>            :     F parent;
<span class="lineNum">    4025 </span>            :     Fp continuation;
<span class="lineNum">    4026 </span>            :     shared_ptr&lt;shared_state_base&gt; centinel;
<span class="lineNum">    4027 </span>            : 
<span class="lineNum">    4028 </span>            :   public:
<span class="lineNum">    4029 </span>            :     future_async_continuation_shared_state(BOOST_THREAD_RV_REF(F) f, BOOST_THREAD_FWD_REF(Fp) c)
<span class="lineNum">    4030 </span>            :     : parent(boost::move(f)),
<span class="lineNum">    4031 </span>            :       continuation(boost::move(c)),
<span class="lineNum">    4032 </span>            :       centinel(parent.future_) {
<span class="lineNum">    4033 </span>            :     }
<span class="lineNum">    4034 </span>            : 
<span class="lineNum">    4035 </span>            : 
<span class="lineNum">    4036 </span>            :     void launch_continuation(boost::unique_lock&lt;boost::mutex&gt;&amp;, shared_ptr&lt;shared_state_base&gt; that) {
<span class="lineNum">    4037 </span>            :       this-&gt;thr_ = thread(&amp;future_async_continuation_shared_state::run, that);
<span class="lineNum">    4038 </span>            :     }
<span class="lineNum">    4039 </span>            : 
<span class="lineNum">    4040 </span>            :     static void run(shared_ptr&lt;boost::detail::shared_state_base&gt; that_) {
<span class="lineNum">    4041 </span>            :       future_async_continuation_shared_state* that = dynamic_cast&lt;future_async_continuation_shared_state*&gt;(that_.get());
<span class="lineNum">    4042 </span>            :       try {
<span class="lineNum">    4043 </span>            :         that-&gt;mark_finished_with_result(that-&gt;continuation(boost::move(that-&gt;parent)));
<span class="lineNum">    4044 </span>            :       } catch(...) {
<span class="lineNum">    4045 </span>            :         that-&gt;mark_exceptional_finish();
<span class="lineNum">    4046 </span>            :       }
<span class="lineNum">    4047 </span>            :     }
<span class="lineNum">    4048 </span>            : 
<span class="lineNum">    4049 </span>            :     ~future_async_continuation_shared_state() {
<span class="lineNum">    4050 </span>            :     }
<span class="lineNum">    4051 </span>            :   };
<span class="lineNum">    4052 </span>            : 
<span class="lineNum">    4053 </span>            :   template&lt;typename F, typename Fp&gt;
<span class="lineNum">    4054 </span>            :   struct future_async_continuation_shared_state&lt;F, void, Fp&gt;: public future_async_shared_state_base&lt;void&gt;
<span class="lineNum">    4055 </span>            :   {
<span class="lineNum">    4056 </span>            :     F parent;
<span class="lineNum">    4057 </span>            :     Fp continuation;
<span class="lineNum">    4058 </span>            :     shared_ptr&lt;shared_state_base&gt; centinel;
<span class="lineNum">    4059 </span>            : 
<span class="lineNum">    4060 </span>            :   public:
<span class="lineNum">    4061 </span>            :     future_async_continuation_shared_state(BOOST_THREAD_RV_REF(F) f, BOOST_THREAD_FWD_REF(Fp) c)
<span class="lineNum">    4062 </span>            :     : parent(boost::move(f)),
<span class="lineNum">    4063 </span>            :       continuation(boost::move(c)),
<span class="lineNum">    4064 </span>            :       centinel(parent.future_) {
<span class="lineNum">    4065 </span>            :     }
<span class="lineNum">    4066 </span>            : 
<span class="lineNum">    4067 </span>            :     void launch_continuation(boost::unique_lock&lt;boost::mutex&gt;&amp;, shared_ptr&lt;shared_state_base&gt; that) {
<span class="lineNum">    4068 </span>            :       this-&gt;thr_ = thread(&amp;future_async_continuation_shared_state::run, that);
<span class="lineNum">    4069 </span>            :     }
<span class="lineNum">    4070 </span>            : 
<span class="lineNum">    4071 </span>            :     static void run(shared_ptr&lt;boost::detail::shared_state_base&gt; that_) {
<span class="lineNum">    4072 </span>            :       future_async_continuation_shared_state* that = dynamic_cast&lt;future_async_continuation_shared_state*&gt;(that_.get());
<span class="lineNum">    4073 </span>            :       try {
<span class="lineNum">    4074 </span>            :         that-&gt;continuation(boost::move(that-&gt;parent));
<span class="lineNum">    4075 </span>            :         that-&gt;mark_finished_with_result();
<span class="lineNum">    4076 </span>            :       } catch(...) {
<span class="lineNum">    4077 </span>            :         that-&gt;mark_exceptional_finish();
<span class="lineNum">    4078 </span>            :       }
<span class="lineNum">    4079 </span>            :     }
<span class="lineNum">    4080 </span>            : 
<span class="lineNum">    4081 </span>            :     ~future_async_continuation_shared_state() {}
<span class="lineNum">    4082 </span>            : 
<span class="lineNum">    4083 </span>            :   };
<span class="lineNum">    4084 </span>            : 
<span class="lineNum">    4085 </span>            :   /////////////////////////
<span class="lineNum">    4086 </span>            :   /// future_executor_continuation_shared_state
<span class="lineNum">    4087 </span>            :   /////////////////////////
<span class="lineNum">    4088 </span>            : #ifdef BOOST_THREAD_PROVIDES_EXECUTORS
<span class="lineNum">    4089 </span>            : 
<span class="lineNum">    4090 </span>            :   template &lt;typename FutureExecutorContinuationSharedState&gt;
<span class="lineNum">    4091 </span>            :   struct run_it {
<span class="lineNum">    4092 </span>            :     shared_ptr&lt;boost::detail::shared_state_base&gt; that_;
<span class="lineNum">    4093 </span>            : 
<span class="lineNum">    4094 </span>            :     run_it(shared_ptr&lt;boost::detail::shared_state_base&gt; that) : that_ (that) {}
<span class="lineNum">    4095 </span>            :     void operator()()
<span class="lineNum">    4096 </span>            :     {
<span class="lineNum">    4097 </span>            :       FutureExecutorContinuationSharedState* that = dynamic_cast&lt;FutureExecutorContinuationSharedState*&gt;(that_.get());
<span class="lineNum">    4098 </span>            :       that-&gt;run(that_);
<span class="lineNum">    4099 </span>            :     }
<span class="lineNum">    4100 </span>            :   };
<span class="lineNum">    4101 </span>            : 
<span class="lineNum">    4102 </span>            :   template&lt;typename Ex, typename F, typename Rp, typename Fp&gt;
<span class="lineNum">    4103 </span>            :   struct future_executor_continuation_shared_state: shared_state&lt;Rp&gt;
<span class="lineNum">    4104 </span>            :   {
<span class="lineNum">    4105 </span>            :     Ex* ex;
<span class="lineNum">    4106 </span>            :     F parent;
<span class="lineNum">    4107 </span>            :     Fp continuation;
<span class="lineNum">    4108 </span>            :     shared_ptr&lt;shared_state_base&gt; centinel;
<span class="lineNum">    4109 </span>            : 
<span class="lineNum">    4110 </span>            :   public:
<span class="lineNum">    4111 </span>            :     future_executor_continuation_shared_state(Ex&amp; ex, BOOST_THREAD_RV_REF(F) f, BOOST_THREAD_FWD_REF(Fp) c)
<span class="lineNum">    4112 </span>            :     : ex(&amp;ex), parent(boost::move(f)),
<span class="lineNum">    4113 </span>            :       continuation(boost::move(c)),
<span class="lineNum">    4114 </span>            :       centinel(parent.future_)  {
<span class="lineNum">    4115 </span>            :       this-&gt;set_executor();
<span class="lineNum">    4116 </span>            :     }
<span class="lineNum">    4117 </span>            : 
<span class="lineNum">    4118 </span>            :     void launch_continuation(boost::unique_lock&lt;boost::mutex&gt;&amp; lck, shared_ptr&lt;shared_state_base&gt; that ) {
<span class="lineNum">    4119 </span>            :       relocker relock(lck);
<span class="lineNum">    4120 </span>            :       run_it&lt;future_executor_continuation_shared_state&gt; fct(that);
<span class="lineNum">    4121 </span>            :       ex-&gt;submit(fct);
<span class="lineNum">    4122 </span>            :     }
<span class="lineNum">    4123 </span>            : 
<span class="lineNum">    4124 </span>            :     static void run(shared_ptr&lt;boost::detail::shared_state_base&gt; that_) {
<span class="lineNum">    4125 </span>            :       future_executor_continuation_shared_state* that = dynamic_cast&lt;future_executor_continuation_shared_state*&gt;(that_.get());
<span class="lineNum">    4126 </span>            :       try {
<span class="lineNum">    4127 </span>            :         that-&gt;mark_finished_with_result(that-&gt;continuation(boost::move(that-&gt;parent)));
<span class="lineNum">    4128 </span>            :       } catch(...) {
<span class="lineNum">    4129 </span>            :         that-&gt;mark_exceptional_finish();
<span class="lineNum">    4130 </span>            :       }
<span class="lineNum">    4131 </span>            :     }
<span class="lineNum">    4132 </span>            : 
<span class="lineNum">    4133 </span>            :     virtual void block_if_needed(boost::unique_lock&lt;boost::mutex&gt;&amp;lk)
<span class="lineNum">    4134 </span>            :     {
<span class="lineNum">    4135 </span>            :       this-&gt;wait(lk, false);
<span class="lineNum">    4136 </span>            :     }
<span class="lineNum">    4137 </span>            : 
<span class="lineNum">    4138 </span>            :     ~future_executor_continuation_shared_state() {}
<span class="lineNum">    4139 </span>            :   };
<span class="lineNum">    4140 </span>            : 
<span class="lineNum">    4141 </span>            :   template&lt;typename Ex, typename F, typename Fp&gt;
<span class="lineNum">    4142 </span>            :   struct future_executor_continuation_shared_state&lt;Ex, F, void, Fp&gt;: public shared_state&lt;void&gt;
<span class="lineNum">    4143 </span>            :   {
<span class="lineNum">    4144 </span>            :     Ex* ex;
<span class="lineNum">    4145 </span>            :     F parent;
<span class="lineNum">    4146 </span>            :     Fp continuation;
<span class="lineNum">    4147 </span>            :     shared_ptr&lt;shared_state_base&gt; centinel;
<span class="lineNum">    4148 </span>            : 
<span class="lineNum">    4149 </span>            :   public:
<span class="lineNum">    4150 </span>            :     future_executor_continuation_shared_state(Ex&amp; ex, BOOST_THREAD_RV_REF(F) f, BOOST_THREAD_FWD_REF(Fp) c)
<span class="lineNum">    4151 </span>            :     : ex(&amp;ex), parent(boost::move(f)),
<span class="lineNum">    4152 </span>            :       continuation(boost::move(c)),
<span class="lineNum">    4153 </span>            :       centinel(parent.future_)  {
<span class="lineNum">    4154 </span>            :       this-&gt;set_executor();
<span class="lineNum">    4155 </span>            :     }
<span class="lineNum">    4156 </span>            : 
<span class="lineNum">    4157 </span>            :     void launch_continuation(boost::unique_lock&lt;boost::mutex&gt;&amp; lck, shared_ptr&lt;shared_state_base&gt; that ) {
<span class="lineNum">    4158 </span>            :       relocker relock(lck);
<span class="lineNum">    4159 </span>            :       run_it&lt;future_executor_continuation_shared_state&gt; fct(that);
<span class="lineNum">    4160 </span>            :       ex-&gt;submit(fct);
<span class="lineNum">    4161 </span>            :     }
<span class="lineNum">    4162 </span>            : 
<span class="lineNum">    4163 </span>            :     static void run(shared_ptr&lt;boost::detail::shared_state_base&gt; that_) {
<span class="lineNum">    4164 </span>            :       future_executor_continuation_shared_state* that = dynamic_cast&lt;future_executor_continuation_shared_state*&gt;(that_.get());
<span class="lineNum">    4165 </span>            :       try {
<span class="lineNum">    4166 </span>            :         that-&gt;continuation(boost::move(that-&gt;parent));
<span class="lineNum">    4167 </span>            :         that-&gt;mark_finished_with_result();
<span class="lineNum">    4168 </span>            :       } catch(...) {
<span class="lineNum">    4169 </span>            :         that-&gt;mark_exceptional_finish();
<span class="lineNum">    4170 </span>            :       }
<span class="lineNum">    4171 </span>            :     }
<span class="lineNum">    4172 </span>            : 
<span class="lineNum">    4173 </span>            :     virtual void block_if_needed(boost::unique_lock&lt;boost::mutex&gt;&amp;lk)
<span class="lineNum">    4174 </span>            :     {
<span class="lineNum">    4175 </span>            :       this-&gt;wait(lk, false);
<span class="lineNum">    4176 </span>            :     }
<span class="lineNum">    4177 </span>            : 
<span class="lineNum">    4178 </span>            :     ~future_executor_continuation_shared_state() {}
<span class="lineNum">    4179 </span>            :   };
<span class="lineNum">    4180 </span>            : #endif
<span class="lineNum">    4181 </span>            : 
<span class="lineNum">    4182 </span>            :   /////////////////////////
<span class="lineNum">    4183 </span>            :   /// shared_future_async_continuation_shared_state
<span class="lineNum">    4184 </span>            :   /////////////////////////
<span class="lineNum">    4185 </span>            : 
<span class="lineNum">    4186 </span>            :   template&lt;typename F, typename Rp, typename Fp&gt;
<span class="lineNum">    4187 </span>            :   struct shared_future_async_continuation_shared_state: future_async_shared_state_base&lt;Rp&gt;
<span class="lineNum">    4188 </span>            :   {
<span class="lineNum">    4189 </span>            :     F parent;
<span class="lineNum">    4190 </span>            :     Fp continuation;
<span class="lineNum">    4191 </span>            :     shared_ptr&lt;shared_state_base&gt; centinel;
<span class="lineNum">    4192 </span>            : 
<span class="lineNum">    4193 </span>            :   public:
<span class="lineNum">    4194 </span>            :     shared_future_async_continuation_shared_state(F f, BOOST_THREAD_FWD_REF(Fp) c)
<span class="lineNum">    4195 </span>            :     : parent(f),
<span class="lineNum">    4196 </span>            :       continuation(boost::move(c)),
<span class="lineNum">    4197 </span>            :       centinel(parent.future_)  {
<span class="lineNum">    4198 </span>            :     }
<span class="lineNum">    4199 </span>            : 
<span class="lineNum">    4200 </span>            :     void launch_continuation(boost::unique_lock&lt;boost::mutex&gt;&amp;, shared_ptr&lt;shared_state_base&gt; that) {
<span class="lineNum">    4201 </span>            :       this-&gt;thr_ = thread(&amp;shared_future_async_continuation_shared_state::run, that);
<span class="lineNum">    4202 </span>            :     }
<span class="lineNum">    4203 </span>            : 
<span class="lineNum">    4204 </span>            :     static void run(shared_ptr&lt;boost::detail::shared_state_base&gt; that_) {
<span class="lineNum">    4205 </span>            :       shared_future_async_continuation_shared_state* that = dynamic_cast&lt;shared_future_async_continuation_shared_state*&gt;(that_.get());
<span class="lineNum">    4206 </span>            :       try {
<span class="lineNum">    4207 </span>            :         that-&gt;mark_finished_with_result(that-&gt;continuation(that-&gt;parent));
<span class="lineNum">    4208 </span>            :       } catch(...) {
<span class="lineNum">    4209 </span>            :         that-&gt;mark_exceptional_finish();
<span class="lineNum">    4210 </span>            :       }
<span class="lineNum">    4211 </span>            :     }
<span class="lineNum">    4212 </span>            : 
<span class="lineNum">    4213 </span>            :     ~shared_future_async_continuation_shared_state() {}
<span class="lineNum">    4214 </span>            :   };
<span class="lineNum">    4215 </span>            : 
<span class="lineNum">    4216 </span>            :   template&lt;typename F, typename Fp&gt;
<span class="lineNum">    4217 </span>            :   struct shared_future_async_continuation_shared_state&lt;F, void, Fp&gt;: public future_async_shared_state_base&lt;void&gt;
<span class="lineNum">    4218 </span>            :   {
<span class="lineNum">    4219 </span>            :     F parent;
<span class="lineNum">    4220 </span>            :     Fp continuation;
<span class="lineNum">    4221 </span>            :     shared_ptr&lt;shared_state_base&gt; centinel;
<span class="lineNum">    4222 </span>            : 
<span class="lineNum">    4223 </span>            :   public:
<span class="lineNum">    4224 </span>            :     shared_future_async_continuation_shared_state(F f, BOOST_THREAD_FWD_REF(Fp) c)
<span class="lineNum">    4225 </span>            :     : parent(f),
<span class="lineNum">    4226 </span>            :       continuation(boost::move(c)),
<span class="lineNum">    4227 </span>            :       centinel(parent.future_)  {
<span class="lineNum">    4228 </span>            :     }
<span class="lineNum">    4229 </span>            : 
<span class="lineNum">    4230 </span>            :     void launch_continuation(boost::unique_lock&lt;boost::mutex&gt;&amp;, shared_ptr&lt;shared_state_base&gt; that) {
<span class="lineNum">    4231 </span>            :       this-&gt;thr_ = thread(&amp;shared_future_async_continuation_shared_state::run, that);
<span class="lineNum">    4232 </span>            :     }
<span class="lineNum">    4233 </span>            : 
<span class="lineNum">    4234 </span>            :     static void run(shared_ptr&lt;boost::detail::shared_state_base&gt; that_) {
<span class="lineNum">    4235 </span>            :       shared_future_async_continuation_shared_state* that = dynamic_cast&lt;shared_future_async_continuation_shared_state*&gt;(that_.get());
<span class="lineNum">    4236 </span>            :       try {
<span class="lineNum">    4237 </span>            :         that-&gt;continuation(that-&gt;parent);
<span class="lineNum">    4238 </span>            :         that-&gt;mark_finished_with_result();
<span class="lineNum">    4239 </span>            :       } catch(...) {
<span class="lineNum">    4240 </span>            :         that-&gt;mark_exceptional_finish();
<span class="lineNum">    4241 </span>            :       }
<span class="lineNum">    4242 </span>            :     }
<span class="lineNum">    4243 </span>            : 
<span class="lineNum">    4244 </span>            :     ~shared_future_async_continuation_shared_state() {}
<span class="lineNum">    4245 </span>            :   };
<span class="lineNum">    4246 </span>            : 
<span class="lineNum">    4247 </span>            :   /////////////////////////
<span class="lineNum">    4248 </span>            :   /// shared_future_executor_continuation_shared_state
<span class="lineNum">    4249 </span>            :   /////////////////////////
<span class="lineNum">    4250 </span>            : #ifdef BOOST_THREAD_PROVIDES_EXECUTORS
<span class="lineNum">    4251 </span>            : 
<span class="lineNum">    4252 </span>            :   template&lt;typename Ex, typename F, typename Rp, typename Fp&gt;
<span class="lineNum">    4253 </span>            :   struct shared_future_executor_continuation_shared_state: shared_state&lt;Rp&gt;
<span class="lineNum">    4254 </span>            :   {
<span class="lineNum">    4255 </span>            :     Ex* ex;
<span class="lineNum">    4256 </span>            :     F parent;
<span class="lineNum">    4257 </span>            :     Fp continuation;
<span class="lineNum">    4258 </span>            :     shared_ptr&lt;shared_state_base&gt; centinel;
<span class="lineNum">    4259 </span>            : 
<span class="lineNum">    4260 </span>            :   public:
<span class="lineNum">    4261 </span>            :     shared_future_executor_continuation_shared_state(Ex&amp; ex, F f, BOOST_THREAD_FWD_REF(Fp) c)
<span class="lineNum">    4262 </span>            :     : ex(&amp;ex), parent(f),
<span class="lineNum">    4263 </span>            :       continuation(boost::move(c)),
<span class="lineNum">    4264 </span>            :       centinel(parent.future_)  {
<span class="lineNum">    4265 </span>            :       this-&gt;set_executor();
<span class="lineNum">    4266 </span>            :     }
<span class="lineNum">    4267 </span>            : 
<span class="lineNum">    4268 </span>            :     void launch_continuation(boost::unique_lock&lt;boost::mutex&gt;&amp; lck, shared_ptr&lt;shared_state_base&gt; that) {
<span class="lineNum">    4269 </span>            :       relocker relock(lck);
<span class="lineNum">    4270 </span>            :       run_it&lt;shared_future_executor_continuation_shared_state&gt; fct(that);
<span class="lineNum">    4271 </span>            :       ex-&gt;submit(fct);
<span class="lineNum">    4272 </span>            :     }
<span class="lineNum">    4273 </span>            : 
<span class="lineNum">    4274 </span>            :     static void run(shared_ptr&lt;boost::detail::shared_state_base&gt; that_) {
<span class="lineNum">    4275 </span>            :       shared_future_executor_continuation_shared_state* that = dynamic_cast&lt;shared_future_executor_continuation_shared_state*&gt;(that_.get());
<span class="lineNum">    4276 </span>            :       try {
<span class="lineNum">    4277 </span>            :         that-&gt;mark_finished_with_result(that-&gt;continuation(that-&gt;parent));
<span class="lineNum">    4278 </span>            :       } catch(...) {
<span class="lineNum">    4279 </span>            :         that-&gt;mark_exceptional_finish();
<span class="lineNum">    4280 </span>            :       }
<span class="lineNum">    4281 </span>            :     }
<span class="lineNum">    4282 </span>            : 
<span class="lineNum">    4283 </span>            :     virtual void block_if_needed(boost::unique_lock&lt;boost::mutex&gt;&amp;lk)
<span class="lineNum">    4284 </span>            :     {
<span class="lineNum">    4285 </span>            :       this-&gt;wait(lk, false);
<span class="lineNum">    4286 </span>            :     }
<span class="lineNum">    4287 </span>            : 
<span class="lineNum">    4288 </span>            :     ~shared_future_executor_continuation_shared_state() {}
<span class="lineNum">    4289 </span>            :   };
<span class="lineNum">    4290 </span>            : 
<span class="lineNum">    4291 </span>            :   template&lt;typename Ex, typename F, typename Fp&gt;
<span class="lineNum">    4292 </span>            :   struct shared_future_executor_continuation_shared_state&lt;Ex, F, void, Fp&gt;: public shared_state&lt;void&gt;
<span class="lineNum">    4293 </span>            :   {
<span class="lineNum">    4294 </span>            :     Ex* ex;
<span class="lineNum">    4295 </span>            :     F parent;
<span class="lineNum">    4296 </span>            :     Fp continuation;
<span class="lineNum">    4297 </span>            :     shared_ptr&lt;shared_state_base&gt; centinel;
<span class="lineNum">    4298 </span>            : 
<span class="lineNum">    4299 </span>            :   public:
<span class="lineNum">    4300 </span>            :     shared_future_executor_continuation_shared_state(Ex&amp; ex, F f, BOOST_THREAD_FWD_REF(Fp) c)
<span class="lineNum">    4301 </span>            :     : ex(&amp;ex), parent(f),
<span class="lineNum">    4302 </span>            :       continuation(boost::move(c)),
<span class="lineNum">    4303 </span>            :       centinel(parent.future_) {
<span class="lineNum">    4304 </span>            :     }
<span class="lineNum">    4305 </span>            : 
<span class="lineNum">    4306 </span>            :     void launch_continuation(boost::unique_lock&lt;boost::mutex&gt;&amp; lck, shared_ptr&lt;shared_state_base&gt; that) {
<span class="lineNum">    4307 </span>            :       relocker relock(lck);
<span class="lineNum">    4308 </span>            :       run_it&lt;shared_future_executor_continuation_shared_state&gt; fct(that);
<span class="lineNum">    4309 </span>            :       ex-&gt;submit(fct);
<span class="lineNum">    4310 </span>            :     }
<span class="lineNum">    4311 </span>            : 
<span class="lineNum">    4312 </span>            :     static void run(shared_ptr&lt;boost::detail::shared_state_base&gt; that_) {
<span class="lineNum">    4313 </span>            :       shared_future_executor_continuation_shared_state* that = dynamic_cast&lt;shared_future_executor_continuation_shared_state*&gt;(that_.get());
<span class="lineNum">    4314 </span>            :       try {
<span class="lineNum">    4315 </span>            :         that-&gt;continuation(that-&gt;parent);
<span class="lineNum">    4316 </span>            :         that-&gt;mark_finished_with_result();
<span class="lineNum">    4317 </span>            :       } catch(...) {
<span class="lineNum">    4318 </span>            :         that-&gt;mark_exceptional_finish();
<span class="lineNum">    4319 </span>            :       }
<span class="lineNum">    4320 </span>            :     }
<span class="lineNum">    4321 </span>            : 
<span class="lineNum">    4322 </span>            :     virtual void block_if_needed(boost::unique_lock&lt;boost::mutex&gt;&amp;lk)
<span class="lineNum">    4323 </span>            :     {
<span class="lineNum">    4324 </span>            :       this-&gt;wait(lk, false);
<span class="lineNum">    4325 </span>            :     }
<span class="lineNum">    4326 </span>            : 
<span class="lineNum">    4327 </span>            :     ~shared_future_executor_continuation_shared_state() {}
<span class="lineNum">    4328 </span>            :   };
<span class="lineNum">    4329 </span>            : #endif
<span class="lineNum">    4330 </span>            :   //////////////////////////
<span class="lineNum">    4331 </span>            :   /// future_deferred_continuation_shared_state
<span class="lineNum">    4332 </span>            :   //////////////////////////
<span class="lineNum">    4333 </span>            :   template&lt;typename F, typename Rp, typename Fp&gt;
<span class="lineNum">    4334 </span>            :   struct future_deferred_continuation_shared_state: shared_state&lt;Rp&gt;
<span class="lineNum">    4335 </span>            :   {
<span class="lineNum">    4336 </span>            :     F parent;
<span class="lineNum">    4337 </span>            :     Fp continuation;
<span class="lineNum">    4338 </span>            :     shared_ptr&lt;shared_state_base&gt; centinel;
<span class="lineNum">    4339 </span>            : 
<span class="lineNum">    4340 </span>            :   public:
<span class="lineNum">    4341 </span>            :     future_deferred_continuation_shared_state(BOOST_THREAD_RV_REF(F) f, BOOST_THREAD_FWD_REF(Fp) c)
<span class="lineNum">    4342 </span>            :     : parent(boost::move(f)),
<span class="lineNum">    4343 </span>            :       continuation(boost::move(c)),
<span class="lineNum">    4344 </span>            :       centinel(parent.future_) {
<span class="lineNum">    4345 </span>            :       this-&gt;set_deferred();
<span class="lineNum">    4346 </span>            :     }
<span class="lineNum">    4347 </span>            : 
<span class="lineNum">    4348 </span>            :     virtual void launch_continuation(boost::unique_lock&lt;boost::mutex&gt;&amp;lk, shared_ptr&lt;shared_state_base&gt; ) {
<span class="lineNum">    4349 </span>            :       if (this-&gt;is_deferred_) {
<span class="lineNum">    4350 </span>            :         this-&gt;is_deferred_=false;
<span class="lineNum">    4351 </span>            :         this-&gt;execute(lk);
<span class="lineNum">    4352 </span>            :       }
<span class="lineNum">    4353 </span>            :     }
<span class="lineNum">    4354 </span>            : 
<span class="lineNum">    4355 </span>            :     virtual void execute(boost::unique_lock&lt;boost::mutex&gt;&amp; lck) {
<span class="lineNum">    4356 </span>            :       try {
<span class="lineNum">    4357 </span>            :         Fp local_fuct=boost::move(continuation);
<span class="lineNum">    4358 </span>            :         F ftmp = boost::move(parent);
<span class="lineNum">    4359 </span>            :         relocker relock(lck);
<span class="lineNum">    4360 </span>            :         Rp res = local_fuct(boost::move(ftmp));
<span class="lineNum">    4361 </span>            :         relock.lock();
<span class="lineNum">    4362 </span>            :         this-&gt;mark_finished_with_result_internal(boost::move(res), lck);
<span class="lineNum">    4363 </span>            :       } catch (...) {
<span class="lineNum">    4364 </span>            :         this-&gt;mark_exceptional_finish_internal(current_exception(), lck);
<span class="lineNum">    4365 </span>            :       }
<span class="lineNum">    4366 </span>            :     }
<span class="lineNum">    4367 </span>            :   };
<span class="lineNum">    4368 </span>            : 
<span class="lineNum">    4369 </span>            :   template&lt;typename F, typename Fp&gt;
<span class="lineNum">    4370 </span>            :   struct future_deferred_continuation_shared_state&lt;F,void,Fp&gt;: shared_state&lt;void&gt;
<span class="lineNum">    4371 </span>            :   {
<span class="lineNum">    4372 </span>            :     F parent;
<span class="lineNum">    4373 </span>            :     Fp continuation;
<span class="lineNum">    4374 </span>            :     shared_ptr&lt;shared_state_base&gt; centinel;
<span class="lineNum">    4375 </span>            : 
<span class="lineNum">    4376 </span>            :   public:
<span class="lineNum">    4377 </span>            :     future_deferred_continuation_shared_state(BOOST_THREAD_RV_REF(F) f, BOOST_THREAD_FWD_REF(Fp) c)
<span class="lineNum">    4378 </span>            :     : parent(boost::move(f)),
<span class="lineNum">    4379 </span>            :       continuation(boost::move(c)),
<span class="lineNum">    4380 </span>            :       centinel(parent.future_) {
<span class="lineNum">    4381 </span>            :       this-&gt;set_deferred();
<span class="lineNum">    4382 </span>            :     }
<span class="lineNum">    4383 </span>            : 
<span class="lineNum">    4384 </span>            :     ~future_deferred_continuation_shared_state() {
<span class="lineNum">    4385 </span>            :     }
<span class="lineNum">    4386 </span>            :     virtual void launch_continuation(boost::unique_lock&lt;boost::mutex&gt;&amp; lk, shared_ptr&lt;shared_state_base&gt; ) {
<span class="lineNum">    4387 </span>            :       if (this-&gt;is_deferred_) {
<span class="lineNum">    4388 </span>            :         this-&gt;is_deferred_=false;
<span class="lineNum">    4389 </span>            :         this-&gt;execute(lk);
<span class="lineNum">    4390 </span>            :       }
<span class="lineNum">    4391 </span>            :     }
<span class="lineNum">    4392 </span>            : 
<span class="lineNum">    4393 </span>            :     virtual void execute(boost::unique_lock&lt;boost::mutex&gt;&amp; lck) {
<span class="lineNum">    4394 </span>            :       try {
<span class="lineNum">    4395 </span>            :         Fp local_fuct=boost::move(continuation);
<span class="lineNum">    4396 </span>            :         F ftmp = boost::move(parent);
<span class="lineNum">    4397 </span>            :         relocker relock(lck);
<span class="lineNum">    4398 </span>            :         local_fuct(boost::move(ftmp));
<span class="lineNum">    4399 </span>            :         relock.lock();
<span class="lineNum">    4400 </span>            :         this-&gt;mark_finished_with_result_internal(lck);
<span class="lineNum">    4401 </span>            :       } catch (...) {
<span class="lineNum">    4402 </span>            :         this-&gt;mark_exceptional_finish_internal(current_exception(), lck);
<span class="lineNum">    4403 </span>            :       }
<span class="lineNum">    4404 </span>            :     }
<span class="lineNum">    4405 </span>            :   };
<span class="lineNum">    4406 </span>            : 
<span class="lineNum">    4407 </span>            :   //////////////////////////
<span class="lineNum">    4408 </span>            :   /// shared_future_deferred_continuation_shared_state
<span class="lineNum">    4409 </span>            :   //////////////////////////
<span class="lineNum">    4410 </span>            :   template&lt;typename F, typename Rp, typename Fp&gt;
<span class="lineNum">    4411 </span>            :   struct shared_future_deferred_continuation_shared_state: shared_state&lt;Rp&gt;
<span class="lineNum">    4412 </span>            :   {
<span class="lineNum">    4413 </span>            :     F parent;
<span class="lineNum">    4414 </span>            :     Fp continuation;
<span class="lineNum">    4415 </span>            :     shared_ptr&lt;shared_state_base&gt; centinel;
<span class="lineNum">    4416 </span>            : 
<span class="lineNum">    4417 </span>            :   public:
<span class="lineNum">    4418 </span>            :     shared_future_deferred_continuation_shared_state(F f, BOOST_THREAD_FWD_REF(Fp) c)
<span class="lineNum">    4419 </span>            :     : parent(f),
<span class="lineNum">    4420 </span>            :       continuation(boost::move(c)),
<span class="lineNum">    4421 </span>            :       centinel(parent.future_) {
<span class="lineNum">    4422 </span>            :       this-&gt;set_deferred();
<span class="lineNum">    4423 </span>            :     }
<span class="lineNum">    4424 </span>            : 
<span class="lineNum">    4425 </span>            :     virtual void launch_continuation(boost::unique_lock&lt;boost::mutex&gt;&amp; lk, shared_ptr&lt;shared_state_base&gt; ) {
<span class="lineNum">    4426 </span>            :       if (this-&gt;is_deferred_) {
<span class="lineNum">    4427 </span>            :         this-&gt;is_deferred_=false;
<span class="lineNum">    4428 </span>            :         this-&gt;execute(lk);
<span class="lineNum">    4429 </span>            :       }
<span class="lineNum">    4430 </span>            :     }
<span class="lineNum">    4431 </span>            : 
<span class="lineNum">    4432 </span>            :     virtual void execute(boost::unique_lock&lt;boost::mutex&gt;&amp; lck) {
<span class="lineNum">    4433 </span>            :       try {
<span class="lineNum">    4434 </span>            :         Fp local_fuct=boost::move(continuation);
<span class="lineNum">    4435 </span>            :         F ftmp = parent;
<span class="lineNum">    4436 </span>            :         relocker relock(lck);
<span class="lineNum">    4437 </span>            :         Rp res = local_fuct(ftmp);
<span class="lineNum">    4438 </span>            :         relock.lock();
<span class="lineNum">    4439 </span>            :         this-&gt;mark_finished_with_result_internal(boost::move(res), lck);
<span class="lineNum">    4440 </span>            :       } catch (...) {
<span class="lineNum">    4441 </span>            :         this-&gt;mark_exceptional_finish_internal(current_exception(), lck);
<span class="lineNum">    4442 </span>            :       }
<span class="lineNum">    4443 </span>            :     }
<span class="lineNum">    4444 </span>            :   };
<span class="lineNum">    4445 </span>            : 
<span class="lineNum">    4446 </span>            :   template&lt;typename F, typename Fp&gt;
<span class="lineNum">    4447 </span>            :   struct shared_future_deferred_continuation_shared_state&lt;F,void,Fp&gt;: shared_state&lt;void&gt;
<span class="lineNum">    4448 </span>            :   {
<span class="lineNum">    4449 </span>            :     F parent;
<span class="lineNum">    4450 </span>            :     Fp continuation;
<span class="lineNum">    4451 </span>            :     shared_ptr&lt;shared_state_base&gt; centinel;
<span class="lineNum">    4452 </span>            : 
<span class="lineNum">    4453 </span>            :   public:
<span class="lineNum">    4454 </span>            :     shared_future_deferred_continuation_shared_state(F f, BOOST_THREAD_FWD_REF(Fp) c)
<span class="lineNum">    4455 </span>            :     : parent(f),
<span class="lineNum">    4456 </span>            :       continuation(boost::move(c)),
<span class="lineNum">    4457 </span>            :       centinel(parent.future_) {
<span class="lineNum">    4458 </span>            :       this-&gt;set_deferred();
<span class="lineNum">    4459 </span>            :     }
<span class="lineNum">    4460 </span>            : 
<span class="lineNum">    4461 </span>            :     virtual void launch_continuation(boost::unique_lock&lt;boost::mutex&gt;&amp; lk, shared_ptr&lt;shared_state_base&gt; ) {
<span class="lineNum">    4462 </span>            :       if (this-&gt;is_deferred_) {
<span class="lineNum">    4463 </span>            :         this-&gt;is_deferred_=false;
<span class="lineNum">    4464 </span>            :         this-&gt;execute(lk);
<span class="lineNum">    4465 </span>            :       }
<span class="lineNum">    4466 </span>            :     }
<span class="lineNum">    4467 </span>            : 
<span class="lineNum">    4468 </span>            :     virtual void execute(boost::unique_lock&lt;boost::mutex&gt;&amp; lck) {
<span class="lineNum">    4469 </span>            :       try {
<span class="lineNum">    4470 </span>            :         Fp local_fuct=boost::move(continuation);
<span class="lineNum">    4471 </span>            :         F ftmp = parent;
<span class="lineNum">    4472 </span>            :         relocker relock(lck);
<span class="lineNum">    4473 </span>            :         local_fuct(ftmp);
<span class="lineNum">    4474 </span>            :         relock.lock();
<span class="lineNum">    4475 </span>            :         this-&gt;mark_finished_with_result_internal(lck);
<span class="lineNum">    4476 </span>            :       } catch (...) {
<span class="lineNum">    4477 </span>            :         this-&gt;mark_exceptional_finish_internal(current_exception(), lck);
<span class="lineNum">    4478 </span>            :       }
<span class="lineNum">    4479 </span>            :     }
<span class="lineNum">    4480 </span>            :   };
<span class="lineNum">    4481 </span>            : 
<span class="lineNum">    4482 </span>            :   ////////////////////////////////
<span class="lineNum">    4483 </span>            :   // make_future_deferred_continuation_shared_state
<span class="lineNum">    4484 </span>            :   ////////////////////////////////
<span class="lineNum">    4485 </span>            :   template&lt;typename F, typename Rp, typename Fp&gt;
<span class="lineNum">    4486 </span>            :   BOOST_THREAD_FUTURE&lt;Rp&gt;
<span class="lineNum">    4487 </span>            :   make_future_deferred_continuation_shared_state(
<span class="lineNum">    4488 </span>            :       boost::unique_lock&lt;boost::mutex&gt; &amp;lock,
<span class="lineNum">    4489 </span>            :       BOOST_THREAD_RV_REF(F) f, BOOST_THREAD_FWD_REF(Fp) c) {
<span class="lineNum">    4490 </span>            :     shared_ptr&lt;future_deferred_continuation_shared_state&lt;F, Rp, Fp&gt; &gt;
<span class="lineNum">    4491 </span>            :         h(new future_deferred_continuation_shared_state&lt;F, Rp, Fp&gt;(boost::move(f), boost::forward&lt;Fp&gt;(c)));
<span class="lineNum">    4492 </span>            :     lock.lock();
<span class="lineNum">    4493 </span>            :     h-&gt;parent.future_-&gt;set_continuation_ptr(h, lock);
<span class="lineNum">    4494 </span>            :     lock.unlock();
<span class="lineNum">    4495 </span>            :     return BOOST_THREAD_FUTURE&lt;Rp&gt;(h);
<span class="lineNum">    4496 </span>            :   }
<span class="lineNum">    4497 </span>            : 
<span class="lineNum">    4498 </span>            :   ////////////////////////////////
<span class="lineNum">    4499 </span>            :   // make_future_async_continuation_shared_state
<span class="lineNum">    4500 </span>            :   ////////////////////////////////
<span class="lineNum">    4501 </span>            :   template&lt;typename F, typename Rp, typename Fp&gt;
<span class="lineNum">    4502 </span>            :   BOOST_THREAD_FUTURE&lt;Rp&gt;
<span class="lineNum">    4503 </span>            :   make_future_async_continuation_shared_state(
<span class="lineNum">    4504 </span>            :       boost::unique_lock&lt;boost::mutex&gt; &amp;lock, BOOST_THREAD_RV_REF(F) f,
<span class="lineNum">    4505 </span>            :       BOOST_THREAD_FWD_REF(Fp) c) {
<span class="lineNum">    4506 </span>            :     shared_ptr&lt;future_async_continuation_shared_state&lt;F,Rp, Fp&gt; &gt;
<span class="lineNum">    4507 </span>            :         h(new future_async_continuation_shared_state&lt;F,Rp, Fp&gt;(boost::move(f), boost::forward&lt;Fp&gt;(c)));
<span class="lineNum">    4508 </span>            :     lock.lock();
<span class="lineNum">    4509 </span>            :     h-&gt;parent.future_-&gt;set_continuation_ptr(h, lock);
<span class="lineNum">    4510 </span>            :     lock.unlock();
<span class="lineNum">    4511 </span>            : 
<span class="lineNum">    4512 </span>            :     return BOOST_THREAD_FUTURE&lt;Rp&gt;(h);
<span class="lineNum">    4513 </span>            :   }
<span class="lineNum">    4514 </span>            : 
<span class="lineNum">    4515 </span>            :   ////////////////////////////////
<span class="lineNum">    4516 </span>            :   // make_future_executor_continuation_shared_state
<span class="lineNum">    4517 </span>            :   ////////////////////////////////
<span class="lineNum">    4518 </span>            : #ifdef BOOST_THREAD_PROVIDES_EXECUTORS
<span class="lineNum">    4519 </span>            : 
<span class="lineNum">    4520 </span>            :   template&lt;typename Ex, typename F, typename Rp, typename Fp&gt;
<span class="lineNum">    4521 </span>            :   BOOST_THREAD_FUTURE&lt;Rp&gt;
<span class="lineNum">    4522 </span>            :   make_future_executor_continuation_shared_state(Ex&amp; ex,
<span class="lineNum">    4523 </span>            :       boost::unique_lock&lt;boost::mutex&gt; &amp;lock, BOOST_THREAD_RV_REF(F) f,
<span class="lineNum">    4524 </span>            :       BOOST_THREAD_FWD_REF(Fp) c) {
<span class="lineNum">    4525 </span>            :     shared_ptr&lt;future_executor_continuation_shared_state&lt;Ex,F,Rp, Fp&gt; &gt;
<span class="lineNum">    4526 </span>            :         h(new future_executor_continuation_shared_state&lt;Ex, F,Rp, Fp&gt;(ex, boost::move(f), boost::forward&lt;Fp&gt;(c)));
<span class="lineNum">    4527 </span>            :     lock.lock();
<span class="lineNum">    4528 </span>            :     h-&gt;parent.future_-&gt;set_continuation_ptr(h, lock);
<span class="lineNum">    4529 </span>            :     lock.unlock();
<span class="lineNum">    4530 </span>            : 
<span class="lineNum">    4531 </span>            :     return BOOST_THREAD_FUTURE&lt;Rp&gt;(h);
<span class="lineNum">    4532 </span>            :   }
<span class="lineNum">    4533 </span>            : #endif
<span class="lineNum">    4534 </span>            : 
<span class="lineNum">    4535 </span>            :   ////////////////////////////////
<span class="lineNum">    4536 </span>            :   // make_shared_future_deferred_continuation_shared_state
<span class="lineNum">    4537 </span>            :   ////////////////////////////////
<span class="lineNum">    4538 </span>            :   template&lt;typename F, typename Rp, typename Fp&gt;
<span class="lineNum">    4539 </span>            :   BOOST_THREAD_FUTURE&lt;Rp&gt;
<span class="lineNum">    4540 </span>            :   make_shared_future_deferred_continuation_shared_state(
<span class="lineNum">    4541 </span>            :       boost::unique_lock&lt;boost::mutex&gt; &amp;lock,
<span class="lineNum">    4542 </span>            :       F f, BOOST_THREAD_FWD_REF(Fp) c) {
<span class="lineNum">    4543 </span>            :     shared_ptr&lt;shared_future_deferred_continuation_shared_state&lt;F, Rp, Fp&gt; &gt;
<span class="lineNum">    4544 </span>            :         h(new shared_future_deferred_continuation_shared_state&lt;F, Rp, Fp&gt;(f, boost::forward&lt;Fp&gt;(c)));
<span class="lineNum">    4545 </span>            :     lock.lock();
<span class="lineNum">    4546 </span>            :     h-&gt;parent.future_-&gt;set_continuation_ptr(h, lock);
<span class="lineNum">    4547 </span>            :     lock.unlock();
<span class="lineNum">    4548 </span>            : 
<span class="lineNum">    4549 </span>            :     return BOOST_THREAD_FUTURE&lt;Rp&gt;(h);
<span class="lineNum">    4550 </span>            :   }
<span class="lineNum">    4551 </span>            :   ////////////////////////////////
<span class="lineNum">    4552 </span>            :   // make_shared_future_async_continuation_shared_state
<span class="lineNum">    4553 </span>            :   ////////////////////////////////
<span class="lineNum">    4554 </span>            :   template&lt;typename F, typename Rp, typename Fp&gt;
<span class="lineNum">    4555 </span>            :   BOOST_THREAD_FUTURE&lt;Rp&gt;
<span class="lineNum">    4556 </span>            :   make_shared_future_async_continuation_shared_state(
<span class="lineNum">    4557 </span>            :       boost::unique_lock&lt;boost::mutex&gt; &amp;lock, F f,
<span class="lineNum">    4558 </span>            :       BOOST_THREAD_FWD_REF(Fp) c) {
<span class="lineNum">    4559 </span>            :     shared_ptr&lt;shared_future_async_continuation_shared_state&lt;F,Rp, Fp&gt; &gt;
<span class="lineNum">    4560 </span>            :         h(new shared_future_async_continuation_shared_state&lt;F,Rp, Fp&gt;(f, boost::forward&lt;Fp&gt;(c)));
<span class="lineNum">    4561 </span>            :     lock.lock();
<span class="lineNum">    4562 </span>            :     h-&gt;parent.future_-&gt;set_continuation_ptr(h, lock);
<span class="lineNum">    4563 </span>            :     lock.unlock();
<span class="lineNum">    4564 </span>            : 
<span class="lineNum">    4565 </span>            :     return BOOST_THREAD_FUTURE&lt;Rp&gt;(h);
<span class="lineNum">    4566 </span>            :   }
<span class="lineNum">    4567 </span>            :   ////////////////////////////////
<span class="lineNum">    4568 </span>            :   // make_shared_future_executor_continuation_shared_state
<span class="lineNum">    4569 </span>            :   ////////////////////////////////
<span class="lineNum">    4570 </span>            : #ifdef BOOST_THREAD_PROVIDES_EXECUTORS
<span class="lineNum">    4571 </span>            :   template&lt;typename Ex, typename F, typename Rp, typename Fp&gt;
<span class="lineNum">    4572 </span>            :   BOOST_THREAD_FUTURE&lt;Rp&gt;
<span class="lineNum">    4573 </span>            :   make_shared_future_executor_continuation_shared_state(Ex&amp; ex,
<span class="lineNum">    4574 </span>            :       boost::unique_lock&lt;boost::mutex&gt; &amp;lock, F f,
<span class="lineNum">    4575 </span>            :       BOOST_THREAD_FWD_REF(Fp) c) {
<span class="lineNum">    4576 </span>            :     shared_ptr&lt;shared_future_executor_continuation_shared_state&lt;Ex, F, Rp, Fp&gt; &gt;
<span class="lineNum">    4577 </span>            :         h(new shared_future_executor_continuation_shared_state&lt;Ex, F, Rp, Fp&gt;(ex, f, boost::forward&lt;Fp&gt;(c)));
<span class="lineNum">    4578 </span>            :     lock.lock();
<span class="lineNum">    4579 </span>            :     h-&gt;parent.future_-&gt;set_continuation_ptr(h, lock);
<span class="lineNum">    4580 </span>            :     lock.unlock();
<span class="lineNum">    4581 </span>            : 
<span class="lineNum">    4582 </span>            :     return BOOST_THREAD_FUTURE&lt;Rp&gt;(h);
<span class="lineNum">    4583 </span>            :   }
<span class="lineNum">    4584 </span>            : #endif
<span class="lineNum">    4585 </span>            : }
<span class="lineNum">    4586 </span>            : 
<span class="lineNum">    4587 </span>            :   ////////////////////////////////
<span class="lineNum">    4588 </span>            :   // template&lt;typename F&gt;
<span class="lineNum">    4589 </span>            :   // auto future&lt;R&gt;::then(F&amp;&amp; func) -&gt; BOOST_THREAD_FUTURE&lt;decltype(func(*this))&gt;;
<span class="lineNum">    4590 </span>            :   ////////////////////////////////
<span class="lineNum">    4591 </span>            : 
<span class="lineNum">    4592 </span>            :   template &lt;typename R&gt;
<span class="lineNum">    4593 </span>            :   template &lt;typename F&gt;
<span class="lineNum">    4594 </span>            :   inline BOOST_THREAD_FUTURE&lt;typename boost::result_of&lt;F(BOOST_THREAD_FUTURE&lt;R&gt;)&gt;::type&gt;
<span class="lineNum">    4595 </span>            :   BOOST_THREAD_FUTURE&lt;R&gt;::then(launch policy, BOOST_THREAD_FWD_REF(F) func) {
<span class="lineNum">    4596 </span>            :     typedef typename boost::result_of&lt;F(BOOST_THREAD_FUTURE&lt;R&gt;)&gt;::type future_type;
<span class="lineNum">    4597 </span>            :     BOOST_THREAD_ASSERT_PRECONDITION(this-&gt;future_!=0, future_uninitialized());
<span class="lineNum">    4598 </span>            : 
<span class="lineNum">    4599 </span>            :     boost::unique_lock&lt;boost::mutex&gt; lock(this-&gt;future_-&gt;mutex);
<span class="lineNum">    4600 </span>            :     if (underlying_cast&lt;int&gt;(policy) &amp; int(launch::async)) {
<span class="lineNum">    4601 </span>            :       lock.unlock();
<span class="lineNum">    4602 </span>            :       return BOOST_THREAD_MAKE_RV_REF((boost::detail::make_future_async_continuation_shared_state&lt;BOOST_THREAD_FUTURE&lt;R&gt;, future_type, F&gt;(
<span class="lineNum">    4603 </span>            :                   lock, boost::move(*this), boost::forward&lt;F&gt;(func)
<span class="lineNum">    4604 </span>            :               )));
<span class="lineNum">    4605 </span>            :     } else if (underlying_cast&lt;int&gt;(policy) &amp; int(launch::deferred)) {
<span class="lineNum">    4606 </span>            :       this-&gt;future_-&gt;wait_internal(lock);
<span class="lineNum">    4607 </span>            :       lock.unlock();
<span class="lineNum">    4608 </span>            :       return BOOST_THREAD_MAKE_RV_REF((boost::detail::make_future_deferred_continuation_shared_state&lt;BOOST_THREAD_FUTURE&lt;R&gt;, future_type, F&gt;(
<span class="lineNum">    4609 </span>            :                   lock, boost::move(*this), boost::forward&lt;F&gt;(func)
<span class="lineNum">    4610 </span>            :               )));
<span class="lineNum">    4611 </span>            :     } else {
<span class="lineNum">    4612 </span>            :       lock.unlock();
<span class="lineNum">    4613 </span>            :       return BOOST_THREAD_MAKE_RV_REF((boost::detail::make_future_async_continuation_shared_state&lt;BOOST_THREAD_FUTURE&lt;R&gt;, future_type, F&gt;(
<span class="lineNum">    4614 </span>            :                   lock, boost::move(*this), boost::forward&lt;F&gt;(func)
<span class="lineNum">    4615 </span>            :               )));
<span class="lineNum">    4616 </span>            :     }
<span class="lineNum">    4617 </span>            :   }
<span class="lineNum">    4618 </span>            : #ifdef BOOST_THREAD_PROVIDES_EXECUTORS
<span class="lineNum">    4619 </span>            :   template &lt;typename R&gt;
<span class="lineNum">    4620 </span>            :   template &lt;typename Ex, typename F&gt;
<span class="lineNum">    4621 </span>            :   inline BOOST_THREAD_FUTURE&lt;typename boost::result_of&lt;F(BOOST_THREAD_FUTURE&lt;R&gt;)&gt;::type&gt;
<span class="lineNum">    4622 </span>            :   BOOST_THREAD_FUTURE&lt;R&gt;::then(Ex&amp; ex, BOOST_THREAD_FWD_REF(F) func) {
<span class="lineNum">    4623 </span>            :     typedef typename boost::result_of&lt;F(BOOST_THREAD_FUTURE&lt;R&gt;)&gt;::type future_type;
<span class="lineNum">    4624 </span>            :     BOOST_THREAD_ASSERT_PRECONDITION(this-&gt;future_!=0, future_uninitialized());
<span class="lineNum">    4625 </span>            : 
<span class="lineNum">    4626 </span>            :     boost::unique_lock&lt;boost::mutex&gt; lock(this-&gt;future_-&gt;mutex);
<span class="lineNum">    4627 </span>            :     lock.unlock();
<span class="lineNum">    4628 </span>            :     return BOOST_THREAD_MAKE_RV_REF((boost::detail::make_future_executor_continuation_shared_state&lt;Ex, BOOST_THREAD_FUTURE&lt;R&gt;, future_type, F&gt;(ex,
<span class="lineNum">    4629 </span>            :                   lock, boost::move(*this), boost::forward&lt;F&gt;(func)
<span class="lineNum">    4630 </span>            :               )));
<span class="lineNum">    4631 </span>            :   }
<span class="lineNum">    4632 </span>            : #endif
<span class="lineNum">    4633 </span>            :   template &lt;typename R&gt;
<span class="lineNum">    4634 </span>            :   template &lt;typename F&gt;
<span class="lineNum">    4635 </span>            :   inline BOOST_THREAD_FUTURE&lt;typename boost::result_of&lt;F(BOOST_THREAD_FUTURE&lt;R&gt;)&gt;::type&gt;
<span class="lineNum">    4636 </span>            :   BOOST_THREAD_FUTURE&lt;R&gt;::then(BOOST_THREAD_FWD_REF(F) func)  {
<span class="lineNum">    4637 </span>            :     typedef typename boost::result_of&lt;F(BOOST_THREAD_FUTURE&lt;R&gt;)&gt;::type future_type;
<span class="lineNum">    4638 </span>            :     BOOST_THREAD_ASSERT_PRECONDITION(this-&gt;future_!=0, future_uninitialized());
<span class="lineNum">    4639 </span>            : 
<span class="lineNum">    4640 </span>            :     boost::unique_lock&lt;boost::mutex&gt; lock(this-&gt;future_-&gt;mutex);
<span class="lineNum">    4641 </span>            :     if (underlying_cast&lt;int&gt;(this-&gt;launch_policy(lock)) &amp; int(launch::async)) {
<span class="lineNum">    4642 </span>            :       lock.unlock();
<span class="lineNum">    4643 </span>            :       return boost::detail::make_future_async_continuation_shared_state&lt;BOOST_THREAD_FUTURE&lt;R&gt;, future_type, F&gt;(
<span class="lineNum">    4644 </span>            :           lock, boost::move(*this), boost::forward&lt;F&gt;(func)
<span class="lineNum">    4645 </span>            :       );
<span class="lineNum">    4646 </span>            :     } else if (underlying_cast&lt;int&gt;(this-&gt;launch_policy(lock)) &amp; int(launch::deferred)) {
<span class="lineNum">    4647 </span>            :       this-&gt;future_-&gt;wait_internal(lock);
<span class="lineNum">    4648 </span>            :       lock.unlock();
<span class="lineNum">    4649 </span>            :       return boost::detail::make_future_deferred_continuation_shared_state&lt;BOOST_THREAD_FUTURE&lt;R&gt;, future_type, F&gt;(
<span class="lineNum">    4650 </span>            :           lock, boost::move(*this), boost::forward&lt;F&gt;(func)
<span class="lineNum">    4651 </span>            :       );
<span class="lineNum">    4652 </span>            :     } else {
<span class="lineNum">    4653 </span>            :       lock.unlock();
<span class="lineNum">    4654 </span>            :       return boost::detail::make_future_async_continuation_shared_state&lt;BOOST_THREAD_FUTURE&lt;R&gt;, future_type, F&gt;(
<span class="lineNum">    4655 </span>            :           lock, boost::move(*this), boost::forward&lt;F&gt;(func)
<span class="lineNum">    4656 </span>            :       );
<span class="lineNum">    4657 </span>            :     }
<span class="lineNum">    4658 </span>            :   }
<span class="lineNum">    4659 </span>            : 
<span class="lineNum">    4660 </span>            :   ////////////////////////////////
<span class="lineNum">    4661 </span>            :   // template&lt;typename F&gt;
<span class="lineNum">    4662 </span>            :   // auto future&lt;future&lt;R2&gt;&gt;::then(F&amp;&amp; func) -&gt; BOOST_THREAD_FUTURE&lt;decltype(func(*this))&gt;;
<span class="lineNum">    4663 </span>            :   ////////////////////////////////
<span class="lineNum">    4664 </span>            : 
<span class="lineNum">    4665 </span>            :   template &lt;typename R2&gt;
<span class="lineNum">    4666 </span>            :   template &lt;typename F&gt;
<span class="lineNum">    4667 </span>            :   inline BOOST_THREAD_FUTURE&lt;typename boost::result_of&lt;F(BOOST_THREAD_FUTURE&lt;BOOST_THREAD_FUTURE&lt;R2&gt; &gt;)&gt;::type&gt;
<span class="lineNum">    4668 </span>            :   BOOST_THREAD_FUTURE&lt;BOOST_THREAD_FUTURE&lt;R2&gt; &gt;::then(launch policy, BOOST_THREAD_FWD_REF(F) func) {
<span class="lineNum">    4669 </span>            :     typedef BOOST_THREAD_FUTURE&lt;R2&gt; R;
<span class="lineNum">    4670 </span>            :     typedef typename boost::result_of&lt;F(BOOST_THREAD_FUTURE&lt;R&gt;)&gt;::type future_type;
<span class="lineNum">    4671 </span>            :     BOOST_THREAD_ASSERT_PRECONDITION(this-&gt;future_!=0, future_uninitialized());
<span class="lineNum">    4672 </span>            : 
<span class="lineNum">    4673 </span>            :     boost::unique_lock&lt;boost::mutex&gt; lock(this-&gt;future_-&gt;mutex);
<span class="lineNum">    4674 </span>            :     if (underlying_cast&lt;int&gt;(policy) &amp; int(launch::async)) {
<span class="lineNum">    4675 </span>            :       return BOOST_THREAD_MAKE_RV_REF((boost::detail::make_future_async_continuation_shared_state&lt;BOOST_THREAD_FUTURE&lt;R&gt;, future_type, F&gt;(
<span class="lineNum">    4676 </span>            :                   lock, boost::move(*this), boost::forward&lt;F&gt;(func)
<span class="lineNum">    4677 </span>            :               )));
<span class="lineNum">    4678 </span>            :     } else if (underlying_cast&lt;int&gt;(policy) &amp; int(launch::deferred)) {
<span class="lineNum">    4679 </span>            :       return BOOST_THREAD_MAKE_RV_REF((boost::detail::make_future_deferred_continuation_shared_state&lt;BOOST_THREAD_FUTURE&lt;R&gt;, future_type, F&gt;(
<span class="lineNum">    4680 </span>            :                   lock, boost::move(*this), boost::forward&lt;F&gt;(func)
<span class="lineNum">    4681 </span>            :               )));
<span class="lineNum">    4682 </span>            :     } else {
<span class="lineNum">    4683 </span>            :       return BOOST_THREAD_MAKE_RV_REF((boost::detail::make_future_async_continuation_shared_state&lt;BOOST_THREAD_FUTURE&lt;R&gt;, future_type, F&gt;(
<span class="lineNum">    4684 </span>            :                   lock, boost::move(*this), boost::forward&lt;F&gt;(func)
<span class="lineNum">    4685 </span>            :               )));
<span class="lineNum">    4686 </span>            :     }
<span class="lineNum">    4687 </span>            :   }
<span class="lineNum">    4688 </span>            : #ifdef BOOST_THREAD_PROVIDES_EXECUTORS
<span class="lineNum">    4689 </span>            :   template &lt;typename R2&gt;
<span class="lineNum">    4690 </span>            :   template &lt;typename Ex, typename F&gt;
<span class="lineNum">    4691 </span>            :   inline BOOST_THREAD_FUTURE&lt;typename boost::result_of&lt;F(BOOST_THREAD_FUTURE&lt;BOOST_THREAD_FUTURE&lt;R2&gt; &gt;)&gt;::type&gt;
<span class="lineNum">    4692 </span>            :   BOOST_THREAD_FUTURE&lt;BOOST_THREAD_FUTURE&lt;R2&gt; &gt;::then(Ex&amp; ex, BOOST_THREAD_FWD_REF(F) func) {
<span class="lineNum">    4693 </span>            :     typedef BOOST_THREAD_FUTURE&lt;R2&gt; R;
<span class="lineNum">    4694 </span>            :     typedef typename boost::result_of&lt;F(BOOST_THREAD_FUTURE&lt;R&gt;)&gt;::type future_type;
<span class="lineNum">    4695 </span>            :     BOOST_THREAD_ASSERT_PRECONDITION(this-&gt;future_!=0, future_uninitialized());
<span class="lineNum">    4696 </span>            : 
<span class="lineNum">    4697 </span>            :     boost::unique_lock&lt;boost::mutex&gt; lock(this-&gt;future_-&gt;mutex);
<span class="lineNum">    4698 </span>            :     return BOOST_THREAD_MAKE_RV_REF((boost::detail::make_future_executor_continuation_shared_state&lt;Ex, BOOST_THREAD_FUTURE&lt;R&gt;, future_type, F&gt;(ex,
<span class="lineNum">    4699 </span>            :                   lock, boost::move(*this), boost::forward&lt;F&gt;(func)
<span class="lineNum">    4700 </span>            :               )));
<span class="lineNum">    4701 </span>            :   }
<span class="lineNum">    4702 </span>            : #endif
<span class="lineNum">    4703 </span>            :   template &lt;typename R2&gt;
<span class="lineNum">    4704 </span>            :   template &lt;typename F&gt;
<span class="lineNum">    4705 </span>            :   inline BOOST_THREAD_FUTURE&lt;typename boost::result_of&lt;F(BOOST_THREAD_FUTURE&lt;BOOST_THREAD_FUTURE&lt;R2&gt; &gt;)&gt;::type&gt;
<span class="lineNum">    4706 </span>            :   BOOST_THREAD_FUTURE&lt;BOOST_THREAD_FUTURE&lt;R2&gt; &gt;::then(BOOST_THREAD_FWD_REF(F) func)  {
<span class="lineNum">    4707 </span>            :     typedef BOOST_THREAD_FUTURE&lt;R2&gt; R;
<span class="lineNum">    4708 </span>            :     typedef typename boost::result_of&lt;F(BOOST_THREAD_FUTURE&lt;R&gt;)&gt;::type future_type;
<span class="lineNum">    4709 </span>            :     BOOST_THREAD_ASSERT_PRECONDITION(this-&gt;future_!=0, future_uninitialized());
<span class="lineNum">    4710 </span>            : 
<span class="lineNum">    4711 </span>            :     boost::unique_lock&lt;boost::mutex&gt; lock(this-&gt;future_-&gt;mutex);
<span class="lineNum">    4712 </span>            :     if (underlying_cast&lt;int&gt;(this-&gt;launch_policy(lock)) &amp; int(launch::async)) {
<span class="lineNum">    4713 </span>            :       return boost::detail::make_future_async_continuation_shared_state&lt;BOOST_THREAD_FUTURE&lt;R&gt;, future_type, F&gt;(
<span class="lineNum">    4714 </span>            :           lock, boost::move(*this), boost::forward&lt;F&gt;(func)
<span class="lineNum">    4715 </span>            :       );
<span class="lineNum">    4716 </span>            :     } else if (underlying_cast&lt;int&gt;(this-&gt;launch_policy(lock)) &amp; int(launch::deferred)) {
<span class="lineNum">    4717 </span>            :       this-&gt;future_-&gt;wait_internal(lock);
<span class="lineNum">    4718 </span>            :       return boost::detail::make_future_deferred_continuation_shared_state&lt;BOOST_THREAD_FUTURE&lt;R&gt;, future_type, F&gt;(
<span class="lineNum">    4719 </span>            :           lock, boost::move(*this), boost::forward&lt;F&gt;(func)
<span class="lineNum">    4720 </span>            :       );
<span class="lineNum">    4721 </span>            :     } else {
<span class="lineNum">    4722 </span>            :       return boost::detail::make_future_async_continuation_shared_state&lt;BOOST_THREAD_FUTURE&lt;R&gt;, future_type, F&gt;(
<span class="lineNum">    4723 </span>            :           lock, boost::move(*this), boost::forward&lt;F&gt;(func)
<span class="lineNum">    4724 </span>            :       );
<span class="lineNum">    4725 </span>            :     }
<span class="lineNum">    4726 </span>            :   }
<span class="lineNum">    4727 </span>            : 
<span class="lineNum">    4728 </span>            :   ////////////////////////////////
<span class="lineNum">    4729 </span>            :   // template&lt;typename F&gt;
<span class="lineNum">    4730 </span>            :   // auto shared_future&lt;R&gt;::then(F&amp;&amp; func) -&gt; BOOST_THREAD_FUTURE&lt;decltype(func(*this))&gt;;
<span class="lineNum">    4731 </span>            :   ////////////////////////////////
<span class="lineNum">    4732 </span>            : 
<span class="lineNum">    4733 </span>            :   template &lt;typename R&gt;
<span class="lineNum">    4734 </span>            :   template &lt;typename F&gt;
<span class="lineNum">    4735 </span>            :   inline BOOST_THREAD_FUTURE&lt;typename boost::result_of&lt;F(shared_future&lt;R&gt;)&gt;::type&gt;
<span class="lineNum">    4736 </span>            :   shared_future&lt;R&gt;::then(launch policy, BOOST_THREAD_FWD_REF(F) func)  const
<span class="lineNum">    4737 </span>            :   {
<span class="lineNum">    4738 </span>            :     typedef typename boost::result_of&lt;F(shared_future&lt;R&gt;)&gt;::type future_type;
<span class="lineNum">    4739 </span>            :     BOOST_THREAD_ASSERT_PRECONDITION(this-&gt;future_!=0, future_uninitialized());
<span class="lineNum">    4740 </span>            : 
<span class="lineNum">    4741 </span>            :     boost::unique_lock&lt;boost::mutex&gt; lock(this-&gt;future_-&gt;mutex);
<span class="lineNum">    4742 </span>            :     if (underlying_cast&lt;int&gt;(policy) &amp; int(launch::async)) {
<span class="lineNum">    4743 </span>            :       lock.unlock();
<span class="lineNum">    4744 </span>            :       return BOOST_THREAD_MAKE_RV_REF((boost::detail::make_shared_future_async_continuation_shared_state&lt;shared_future&lt;R&gt;, future_type, F&gt;(
<span class="lineNum">    4745 </span>            :                   lock, *this, boost::forward&lt;F&gt;(func)
<span class="lineNum">    4746 </span>            :               )));
<span class="lineNum">    4747 </span>            :     } else if (underlying_cast&lt;int&gt;(policy) &amp; int(launch::deferred)) {
<span class="lineNum">    4748 </span>            :       this-&gt;future_-&gt;wait_internal(lock);
<span class="lineNum">    4749 </span>            :       lock.unlock();
<span class="lineNum">    4750 </span>            :       return BOOST_THREAD_MAKE_RV_REF((boost::detail::make_shared_future_deferred_continuation_shared_state&lt;shared_future&lt;R&gt;, future_type, F&gt;(
<span class="lineNum">    4751 </span>            :                   lock, *this, boost::forward&lt;F&gt;(func)
<span class="lineNum">    4752 </span>            :               )));
<span class="lineNum">    4753 </span>            :     } else {
<span class="lineNum">    4754 </span>            :       lock.unlock();
<span class="lineNum">    4755 </span>            :       return BOOST_THREAD_MAKE_RV_REF((boost::detail::make_shared_future_async_continuation_shared_state&lt;shared_future&lt;R&gt;, future_type, F&gt;(
<span class="lineNum">    4756 </span>            :                   lock, *this, boost::forward&lt;F&gt;(func)
<span class="lineNum">    4757 </span>            :               )));
<span class="lineNum">    4758 </span>            :     }
<span class="lineNum">    4759 </span>            :   }
<span class="lineNum">    4760 </span>            : #ifdef BOOST_THREAD_PROVIDES_EXECUTORS
<span class="lineNum">    4761 </span>            :   template &lt;typename R&gt;
<span class="lineNum">    4762 </span>            :   template &lt;typename Ex, typename F&gt;
<span class="lineNum">    4763 </span>            :   inline BOOST_THREAD_FUTURE&lt;typename boost::result_of&lt;F(shared_future&lt;R&gt;)&gt;::type&gt;
<span class="lineNum">    4764 </span>            :   shared_future&lt;R&gt;::then(Ex&amp; ex, BOOST_THREAD_FWD_REF(F) func)  const
<span class="lineNum">    4765 </span>            :   {
<span class="lineNum">    4766 </span>            :     typedef typename boost::result_of&lt;F(shared_future&lt;R&gt;)&gt;::type future_type;
<span class="lineNum">    4767 </span>            :     BOOST_THREAD_ASSERT_PRECONDITION(this-&gt;future_!=0, future_uninitialized());
<span class="lineNum">    4768 </span>            : 
<span class="lineNum">    4769 </span>            :     boost::unique_lock&lt;boost::mutex&gt; lock(this-&gt;future_-&gt;mutex);
<span class="lineNum">    4770 </span>            :     lock.unlock();
<span class="lineNum">    4771 </span>            :     return BOOST_THREAD_MAKE_RV_REF((boost::detail::make_shared_future_executor_continuation_shared_state&lt;Ex, shared_future&lt;R&gt;, future_type, F&gt;(ex,
<span class="lineNum">    4772 </span>            :                   lock, *this, boost::forward&lt;F&gt;(func)
<span class="lineNum">    4773 </span>            :               )));
<span class="lineNum">    4774 </span>            :   }
<span class="lineNum">    4775 </span>            : #endif
<span class="lineNum">    4776 </span>            : 
<span class="lineNum">    4777 </span>            :   template &lt;typename R&gt;
<span class="lineNum">    4778 </span>            :   template &lt;typename F&gt;
<span class="lineNum">    4779 </span>            :   inline BOOST_THREAD_FUTURE&lt;typename boost::result_of&lt;F(shared_future&lt;R&gt;)&gt;::type&gt;
<span class="lineNum">    4780 </span>            :   shared_future&lt;R&gt;::then(BOOST_THREAD_FWD_REF(F) func)  const {
<span class="lineNum">    4781 </span>            :     typedef typename boost::result_of&lt;F(shared_future&lt;R&gt;)&gt;::type future_type;
<span class="lineNum">    4782 </span>            : 
<span class="lineNum">    4783 </span>            :     BOOST_THREAD_ASSERT_PRECONDITION(this-&gt;future_!=0, future_uninitialized());
<span class="lineNum">    4784 </span>            : 
<span class="lineNum">    4785 </span>            :     boost::unique_lock&lt;boost::mutex&gt; lock(this-&gt;future_-&gt;mutex);
<span class="lineNum">    4786 </span>            :     if (underlying_cast&lt;int&gt;(this-&gt;launch_policy(lock)) &amp; int(launch::async)) {
<span class="lineNum">    4787 </span>            :       lock.unlock();
<span class="lineNum">    4788 </span>            :       return boost::detail::make_shared_future_async_continuation_shared_state&lt;shared_future&lt;R&gt;, future_type, F&gt;(
<span class="lineNum">    4789 </span>            :           lock, *this, boost::forward&lt;F&gt;(func));
<span class="lineNum">    4790 </span>            :     } else if (underlying_cast&lt;int&gt;(this-&gt;launch_policy(lock)) &amp; int(launch::deferred)) {
<span class="lineNum">    4791 </span>            :       this-&gt;future_-&gt;wait_internal(lock);
<span class="lineNum">    4792 </span>            :       lock.unlock();
<span class="lineNum">    4793 </span>            :       return boost::detail::make_shared_future_deferred_continuation_shared_state&lt;shared_future&lt;R&gt;, future_type, F&gt;(
<span class="lineNum">    4794 </span>            :           lock, *this, boost::forward&lt;F&gt;(func));
<span class="lineNum">    4795 </span>            :     } else {
<span class="lineNum">    4796 </span>            :       lock.unlock();
<span class="lineNum">    4797 </span>            :       return boost::detail::make_shared_future_async_continuation_shared_state&lt;shared_future&lt;R&gt;, future_type, F&gt;(
<span class="lineNum">    4798 </span>            :           lock, *this, boost::forward&lt;F&gt;(func));
<span class="lineNum">    4799 </span>            :     }
<span class="lineNum">    4800 </span>            :   }
<span class="lineNum">    4801 </span>            : 
<span class="lineNum">    4802 </span>            : namespace detail
<span class="lineNum">    4803 </span>            : {
<span class="lineNum">    4804 </span>            :   template &lt;typename T&gt;
<span class="lineNum">    4805 </span>            :   struct mfallbacker_to
<span class="lineNum">    4806 </span>            :   {
<span class="lineNum">    4807 </span>            :     T value_;
<span class="lineNum">    4808 </span>            :     typedef T result_type;
<span class="lineNum">    4809 </span>            :     mfallbacker_to(BOOST_THREAD_RV_REF(T) v)
<span class="lineNum">    4810 </span>            :     : value_(boost::move(v))
<span class="lineNum">    4811 </span>            :     {}
<span class="lineNum">    4812 </span>            : 
<span class="lineNum">    4813 </span>            :     T operator()(BOOST_THREAD_FUTURE&lt;T&gt; fut) {
<span class="lineNum">    4814 </span>            :       return fut.get_or(boost::move(value_));
<span class="lineNum">    4815 </span>            :     }
<span class="lineNum">    4816 </span>            :   };
<span class="lineNum">    4817 </span>            :   template &lt;typename T&gt;
<span class="lineNum">    4818 </span>            :   struct cfallbacker_to
<span class="lineNum">    4819 </span>            :   {
<span class="lineNum">    4820 </span>            :     T value_;
<span class="lineNum">    4821 </span>            :     typedef T result_type;
<span class="lineNum">    4822 </span>            :     cfallbacker_to(T const&amp; v)
<span class="lineNum">    4823 </span>            :     : value_(v)
<span class="lineNum">    4824 </span>            :     {}
<span class="lineNum">    4825 </span>            : 
<span class="lineNum">    4826 </span>            :     T operator()(BOOST_THREAD_FUTURE&lt;T&gt; fut) const {
<span class="lineNum">    4827 </span>            :       return fut.get_or(value_);
<span class="lineNum">    4828 </span>            : 
<span class="lineNum">    4829 </span>            :     }
<span class="lineNum">    4830 </span>            :   };
<span class="lineNum">    4831 </span>            : }
<span class="lineNum">    4832 </span>            :   ////////////////////////////////
<span class="lineNum">    4833 </span>            :   // future&lt;R&gt; future&lt;R&gt;::fallback_to(R&amp;&amp; v);
<span class="lineNum">    4834 </span>            :   ////////////////////////////////
<span class="lineNum">    4835 </span>            : 
<span class="lineNum">    4836 </span>            :   template &lt;typename R&gt;
<span class="lineNum">    4837 </span>            :   template &lt;typename R2&gt;
<span class="lineNum">    4838 </span>            :   inline typename boost::disable_if&lt; is_void&lt;R2&gt;, BOOST_THREAD_FUTURE&lt;R&gt; &gt;::type
<span class="lineNum">    4839 </span>            :   BOOST_THREAD_FUTURE&lt;R&gt;::fallback_to(BOOST_THREAD_RV_REF(R2) v) {
<span class="lineNum">    4840 </span>            :     return then(detail::mfallbacker_to&lt;R&gt;(boost::move(v)));
<span class="lineNum">    4841 </span>            :   }
<span class="lineNum">    4842 </span>            : 
<span class="lineNum">    4843 </span>            :   template &lt;typename R&gt;
<span class="lineNum">    4844 </span>            :   template &lt;typename R2&gt;
<span class="lineNum">    4845 </span>            :   inline typename boost::disable_if&lt; is_void&lt;R2&gt;, BOOST_THREAD_FUTURE&lt;R&gt; &gt;::type
<span class="lineNum">    4846 </span>            :   BOOST_THREAD_FUTURE&lt;R&gt;::fallback_to(R2 const&amp; v) {
<span class="lineNum">    4847 </span>            :     return then(detail::cfallbacker_to&lt;R&gt;(v));
<span class="lineNum">    4848 </span>            :   }
<span class="lineNum">    4849 </span>            : 
<span class="lineNum">    4850 </span>            : #endif
<span class="lineNum">    4851 </span>            : 
<span class="lineNum">    4852 </span>            : #if defined BOOST_THREAD_PROVIDES_FUTURE_UNWRAP
<span class="lineNum">    4853 </span>            : namespace detail
<span class="lineNum">    4854 </span>            : {
<span class="lineNum">    4855 </span>            :   /////////////////////////
<span class="lineNum">    4856 </span>            :   /// future_unwrap_shared_state
<span class="lineNum">    4857 </span>            :   /////////////////////////
<span class="lineNum">    4858 </span>            : 
<span class="lineNum">    4859 </span>            :   template&lt;typename F, typename Rp&gt;
<span class="lineNum">    4860 </span>            :   struct future_unwrap_shared_state: shared_state&lt;Rp&gt;
<span class="lineNum">    4861 </span>            :   {
<span class="lineNum">    4862 </span>            :     F parent;
<span class="lineNum">    4863 </span>            :   public:
<span class="lineNum">    4864 </span>            :     explicit future_unwrap_shared_state(BOOST_THREAD_RV_REF(F) f)
<span class="lineNum">    4865 </span>            :     : parent(boost::move(f)) {}
<span class="lineNum">    4866 </span>            : 
<span class="lineNum">    4867 </span>            :     typename F::value_type parent_value(boost::unique_lock&lt;boost::mutex&gt;&amp; ) {
<span class="lineNum">    4868 </span>            :         typename F::value_type r = parent.get();
<span class="lineNum">    4869 </span>            :         r.set_exceptional_if_invalid();
<span class="lineNum">    4870 </span>            :         return boost::move(r);
<span class="lineNum">    4871 </span>            :     }
<span class="lineNum">    4872 </span>            : 
<span class="lineNum">    4873 </span>            :     virtual void wait(boost::unique_lock&lt;boost::mutex&gt;&amp; lk, bool ) { // todo see if rethrow must be used
<span class="lineNum">    4874 </span>            :         parent_value(lk).wait();
<span class="lineNum">    4875 </span>            :     }
<span class="lineNum">    4876 </span>            :     virtual Rp get(boost::unique_lock&lt;boost::mutex&gt;&amp; lk) {
<span class="lineNum">    4877 </span>            :         return parent_value(lk).get();
<span class="lineNum">    4878 </span>            :     }
<span class="lineNum">    4879 </span>            : #if defined BOOST_THREAD_PROVIDES_FUTURE_CONTINUATION
<span class="lineNum">    4880 </span>            :     typedef shared_ptr&lt;shared_state_base&gt; continuation_ptr_type;
<span class="lineNum">    4881 </span>            : 
<span class="lineNum">    4882 </span>            :     virtual void set_continuation_ptr(continuation_ptr_type continuation, boost::unique_lock&lt;boost::mutex&gt;&amp; lock)
<span class="lineNum">    4883 </span>            :     {
<span class="lineNum">    4884 </span>            :       boost::unique_lock&lt;boost::mutex&gt; lk(parent.future_-&gt;mutex);
<span class="lineNum">    4885 </span>            :       parent.future_-&gt;set_continuation_ptr(continuation, lk);
<span class="lineNum">    4886 </span>            :     }
<span class="lineNum">    4887 </span>            : #endif
<span class="lineNum">    4888 </span>            :   };
<span class="lineNum">    4889 </span>            : 
<span class="lineNum">    4890 </span>            :   template &lt;class F, class Rp&gt;
<span class="lineNum">    4891 </span>            :   BOOST_THREAD_FUTURE&lt;Rp&gt;
<span class="lineNum">    4892 </span>            :   make_future_unwrap_shared_state(boost::unique_lock&lt;boost::mutex&gt; &amp;lock, BOOST_THREAD_RV_REF(F) f) {
<span class="lineNum">    4893 </span>            :     shared_ptr&lt;future_unwrap_shared_state&lt;F, Rp&gt; &gt;
<span class="lineNum">    4894 </span>            :         h(new future_unwrap_shared_state&lt;F, Rp&gt;(boost::move(f)));
<span class="lineNum">    4895 </span>            :     lock.lock();
<span class="lineNum">    4896 </span>            :     h-&gt;parent.future_-&gt;set_continuation_ptr(h, lock);
<span class="lineNum">    4897 </span>            :     lock.unlock();
<span class="lineNum">    4898 </span>            :     return BOOST_THREAD_FUTURE&lt;Rp&gt;(h);
<span class="lineNum">    4899 </span>            :   }
<span class="lineNum">    4900 </span>            : }
<span class="lineNum">    4901 </span>            : 
<span class="lineNum">    4902 </span>            :   template &lt;typename R&gt;
<span class="lineNum">    4903 </span>            :   inline BOOST_THREAD_FUTURE&lt;R&gt;::BOOST_THREAD_FUTURE(BOOST_THREAD_RV_REF(BOOST_THREAD_FUTURE&lt;BOOST_THREAD_FUTURE&lt;R&gt; &gt;) other)
<span class="lineNum">    4904 </span>            :   : base_type(other.unwrap()) {}
<span class="lineNum">    4905 </span>            : 
<span class="lineNum">    4906 </span>            :   template &lt;typename R2&gt;
<span class="lineNum">    4907 </span>            :   BOOST_THREAD_FUTURE&lt;R2&gt;
<span class="lineNum">    4908 </span>            :   BOOST_THREAD_FUTURE&lt;BOOST_THREAD_FUTURE&lt;R2&gt; &gt;::unwrap()
<span class="lineNum">    4909 </span>            :   {
<span class="lineNum">    4910 </span>            :     BOOST_THREAD_ASSERT_PRECONDITION(this-&gt;future_!=0, future_uninitialized());
<span class="lineNum">    4911 </span>            :     boost::unique_lock&lt;boost::mutex&gt; lock(this-&gt;future_-&gt;mutex);
<span class="lineNum">    4912 </span>            :     lock.unlock();
<span class="lineNum">    4913 </span>            :     return boost::detail::make_future_unwrap_shared_state&lt;BOOST_THREAD_FUTURE&lt;BOOST_THREAD_FUTURE&lt;R2&gt; &gt;, R2&gt;(lock, boost::move(*this));
<span class="lineNum">    4914 </span>            :   }
<span class="lineNum">    4915 </span>            : #endif
<span class="lineNum">    4916 </span>            : 
<span class="lineNum">    4917 </span>            : #if defined BOOST_THREAD_PROVIDES_FUTURE_WHEN_ALL_WHEN_ANY
<span class="lineNum">    4918 </span>            : namespace detail
<span class="lineNum">    4919 </span>            : {
<span class="lineNum">    4920 </span>            :   struct input_iterator_tag {};
<span class="lineNum">    4921 </span>            :   struct vector_tag {};
<span class="lineNum">    4922 </span>            :   struct values_tag {};
<span class="lineNum">    4923 </span>            :   template &lt;typename T&gt;
<span class="lineNum">    4924 </span>            :   struct alias_t { typedef T type; };
<span class="lineNum">    4925 </span>            : 
<span class="lineNum">    4926 </span>            :   BOOST_CONSTEXPR_OR_CONST input_iterator_tag input_iterator_tag_value = {};
<span class="lineNum">    4927 </span>            :   BOOST_CONSTEXPR_OR_CONST vector_tag vector_tag_value = {};
<span class="lineNum">    4928 </span>            :   BOOST_CONSTEXPR_OR_CONST values_tag values_tag_value = {};
<span class="lineNum">    4929 </span>            :   ////////////////////////////////
<span class="lineNum">    4930 </span>            :   // detail::future_async_when_all_shared_state
<span class="lineNum">    4931 </span>            :   ////////////////////////////////
<span class="lineNum">    4932 </span>            :   template&lt;typename F&gt;
<span class="lineNum">    4933 </span>            :   struct future_when_all_vector_shared_state: future_async_shared_state_base&lt;csbl::vector&lt;F&gt; &gt;
<span class="lineNum">    4934 </span>            :   {
<span class="lineNum">    4935 </span>            :     typedef csbl::vector&lt;F&gt; vector_type;
<span class="lineNum">    4936 </span>            :     typedef typename F::value_type value_type;
<span class="lineNum">    4937 </span>            :     vector_type vec_;
<span class="lineNum">    4938 </span>            : 
<span class="lineNum">    4939 </span>            :     static void run(shared_ptr&lt;boost::detail::shared_state_base&gt; that_) {
<span class="lineNum">    4940 </span>            :       future_when_all_vector_shared_state* that = dynamic_cast&lt;future_when_all_vector_shared_state*&gt;(that_.get());
<span class="lineNum">    4941 </span>            :       try {
<span class="lineNum">    4942 </span>            :         boost::wait_for_all(that-&gt;vec_.begin(), that-&gt;vec_.end());
<span class="lineNum">    4943 </span>            :         that-&gt;mark_finished_with_result(boost::move(that-&gt;vec_));
<span class="lineNum">    4944 </span>            :       } catch(...) {
<span class="lineNum">    4945 </span>            :         that-&gt;mark_exceptional_finish();
<span class="lineNum">    4946 </span>            :       }
<span class="lineNum">    4947 </span>            :     }
<span class="lineNum">    4948 </span>            :     bool run_deferred() {
<span class="lineNum">    4949 </span>            : 
<span class="lineNum">    4950 </span>            :       bool res = false;
<span class="lineNum">    4951 </span>            :       for (typename csbl::vector&lt;F&gt;::iterator it = vec_.begin(); it != vec_.end(); ++it) {
<span class="lineNum">    4952 </span>            :         if (! it-&gt;run_if_is_deferred())
<span class="lineNum">    4953 </span>            :         {
<span class="lineNum">    4954 </span>            :           res = true;
<span class="lineNum">    4955 </span>            :         }
<span class="lineNum">    4956 </span>            :       }
<span class="lineNum">    4957 </span>            :       return res;
<span class="lineNum">    4958 </span>            :     }
<span class="lineNum">    4959 </span>            :     void init() {
<span class="lineNum">    4960 </span>            :       if (! run_deferred())
<span class="lineNum">    4961 </span>            :       {
<span class="lineNum">    4962 </span>            :         future_when_all_vector_shared_state::run(this-&gt;shared_from_this());
<span class="lineNum">    4963 </span>            :         return;
<span class="lineNum">    4964 </span>            :       }
<span class="lineNum">    4965 </span>            :       this-&gt;thr_ = thread(&amp;future_when_all_vector_shared_state::run, this-&gt;shared_from_this());
<span class="lineNum">    4966 </span>            :     }
<span class="lineNum">    4967 </span>            : 
<span class="lineNum">    4968 </span>            :   public:
<span class="lineNum">    4969 </span>            :     template&lt; typename InputIterator&gt;
<span class="lineNum">    4970 </span>            :     future_when_all_vector_shared_state(input_iterator_tag, InputIterator first, InputIterator last)
<span class="lineNum">    4971 </span>            :     : vec_(std::make_move_iterator(first), std::make_move_iterator(last))
<span class="lineNum">    4972 </span>            :     {
<span class="lineNum">    4973 </span>            :     }
<span class="lineNum">    4974 </span>            : 
<span class="lineNum">    4975 </span>            :     future_when_all_vector_shared_state(vector_tag, BOOST_THREAD_RV_REF(csbl::vector&lt;F&gt;) v)
<span class="lineNum">    4976 </span>            :     : vec_(boost::move(v))
<span class="lineNum">    4977 </span>            :     {
<span class="lineNum">    4978 </span>            :     }
<span class="lineNum">    4979 </span>            : 
<span class="lineNum">    4980 </span>            : #if ! defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
<span class="lineNum">    4981 </span>            :     template&lt; typename T0, typename ...T&gt;
<span class="lineNum">    4982 </span>            :     future_when_all_vector_shared_state(values_tag, BOOST_THREAD_FWD_REF(T0) f, BOOST_THREAD_FWD_REF(T) ... futures) {
<span class="lineNum">    4983 </span>            :       vec_.push_back(boost::forward&lt;T0&gt;(f));
<span class="lineNum">    4984 </span>            :       typename alias_t&lt;char[]&gt;::type{
<span class="lineNum">    4985 </span>            :           ( //first part of magic unpacker
<span class="lineNum">    4986 </span>            :           vec_.push_back(boost::forward&lt;T&gt;(futures)),'0'
<span class="lineNum">    4987 </span>            :           )..., '0'
<span class="lineNum">    4988 </span>            :       }; //second part of magic unpacker
<span class="lineNum">    4989 </span>            :     }
<span class="lineNum">    4990 </span>            : #endif
<span class="lineNum">    4991 </span>            : 
<span class="lineNum">    4992 </span>            :     ~future_when_all_vector_shared_state() {}
<span class="lineNum">    4993 </span>            :   };
<span class="lineNum">    4994 </span>            : 
<span class="lineNum">    4995 </span>            :   ////////////////////////////////
<span class="lineNum">    4996 </span>            :   // detail::future_async_when_any_shared_state
<span class="lineNum">    4997 </span>            :   ////////////////////////////////
<span class="lineNum">    4998 </span>            :   template&lt;typename F&gt;
<span class="lineNum">    4999 </span>            :   struct future_when_any_vector_shared_state: future_async_shared_state_base&lt;csbl::vector&lt;F&gt; &gt;
<span class="lineNum">    5000 </span>            :   {
<span class="lineNum">    5001 </span>            :     typedef csbl::vector&lt;F&gt; vector_type;
<span class="lineNum">    5002 </span>            :     typedef typename F::value_type value_type;
<span class="lineNum">    5003 </span>            :     vector_type vec_;
<span class="lineNum">    5004 </span>            : 
<span class="lineNum">    5005 </span>            :     static void run(shared_ptr&lt;boost::detail::shared_state_base&gt; that_)
<span class="lineNum">    5006 </span>            :     {
<span class="lineNum">    5007 </span>            :       future_when_any_vector_shared_state* that = dynamic_cast&lt;future_when_any_vector_shared_state*&gt;(that_.get());
<span class="lineNum">    5008 </span>            :       try {
<span class="lineNum">    5009 </span>            :         boost::wait_for_any(that-&gt;vec_.begin(), that-&gt;vec_.end());
<span class="lineNum">    5010 </span>            :         that-&gt;mark_finished_with_result(boost::move(that-&gt;vec_));
<span class="lineNum">    5011 </span>            :       } catch(...) {
<span class="lineNum">    5012 </span>            :         that-&gt;mark_exceptional_finish();
<span class="lineNum">    5013 </span>            :       }
<span class="lineNum">    5014 </span>            :     }
<span class="lineNum">    5015 </span>            :     bool run_deferred() {
<span class="lineNum">    5016 </span>            : 
<span class="lineNum">    5017 </span>            :       for (typename csbl::vector&lt;F&gt;::iterator it = vec_.begin(); it != vec_.end(); ++it) {
<span class="lineNum">    5018 </span>            :         if (it-&gt;run_if_is_deferred_or_ready())
<span class="lineNum">    5019 </span>            :         {
<span class="lineNum">    5020 </span>            :           return true;
<span class="lineNum">    5021 </span>            :         }
<span class="lineNum">    5022 </span>            :       }
<span class="lineNum">    5023 </span>            :       return false;
<span class="lineNum">    5024 </span>            :     }
<span class="lineNum">    5025 </span>            :     void init() {
<span class="lineNum">    5026 </span>            :       if (run_deferred())
<span class="lineNum">    5027 </span>            :       {
<span class="lineNum">    5028 </span>            :         future_when_any_vector_shared_state::run(this-&gt;shared_from_this());
<span class="lineNum">    5029 </span>            :         return;
<span class="lineNum">    5030 </span>            :       }
<span class="lineNum">    5031 </span>            : 
<span class="lineNum">    5032 </span>            :       this-&gt;thr_ = thread(&amp;future_when_any_vector_shared_state::run, this-&gt;shared_from_this());
<span class="lineNum">    5033 </span>            :     }
<span class="lineNum">    5034 </span>            : 
<span class="lineNum">    5035 </span>            :   public:
<span class="lineNum">    5036 </span>            :     template&lt; typename InputIterator&gt;
<span class="lineNum">    5037 </span>            :     future_when_any_vector_shared_state(input_iterator_tag, InputIterator first, InputIterator last)
<span class="lineNum">    5038 </span>            :     : vec_(std::make_move_iterator(first), std::make_move_iterator(last))
<span class="lineNum">    5039 </span>            :     {
<span class="lineNum">    5040 </span>            :     }
<span class="lineNum">    5041 </span>            : 
<span class="lineNum">    5042 </span>            :     future_when_any_vector_shared_state(vector_tag, BOOST_THREAD_RV_REF(csbl::vector&lt;F&gt;) v)
<span class="lineNum">    5043 </span>            :     : vec_(boost::move(v))
<span class="lineNum">    5044 </span>            :     {
<span class="lineNum">    5045 </span>            :     }
<span class="lineNum">    5046 </span>            : 
<span class="lineNum">    5047 </span>            : #if ! defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
<span class="lineNum">    5048 </span>            :     template&lt; typename T0, typename ...T&gt;
<span class="lineNum">    5049 </span>            :     future_when_any_vector_shared_state(values_tag,
<span class="lineNum">    5050 </span>            :         BOOST_THREAD_FWD_REF(T0) f, BOOST_THREAD_FWD_REF(T) ... futures
<span class="lineNum">    5051 </span>            :     ) {
<span class="lineNum">    5052 </span>            :       vec_.push_back(boost::forward&lt;T0&gt;(f));
<span class="lineNum">    5053 </span>            :       typename alias_t&lt;char[]&gt;::type{
<span class="lineNum">    5054 </span>            :           ( //first part of magic unpacker
<span class="lineNum">    5055 </span>            :           vec_.push_back(boost::forward&lt;T&gt;(futures))
<span class="lineNum">    5056 </span>            :           ,'0'
<span class="lineNum">    5057 </span>            :           )...,
<span class="lineNum">    5058 </span>            :           '0'
<span class="lineNum">    5059 </span>            :       }; //second part of magic unpacker
<span class="lineNum">    5060 </span>            :     }
<span class="lineNum">    5061 </span>            : #endif
<span class="lineNum">    5062 </span>            : 
<span class="lineNum">    5063 </span>            :     ~future_when_any_vector_shared_state() {}
<span class="lineNum">    5064 </span>            :   };
<span class="lineNum">    5065 </span>            : 
<span class="lineNum">    5066 </span>            : #if ! defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
<span class="lineNum">    5067 </span>            :   struct wait_for_all_fctr {
<span class="lineNum">    5068 </span>            :     template &lt;class ...T&gt;
<span class="lineNum">    5069 </span>            :     void operator()(T&amp;&amp;... v) {
<span class="lineNum">    5070 </span>            :       boost::wait_for_all(boost::forward&lt;T&gt;(v)...);
<span class="lineNum">    5071 </span>            :     }
<span class="lineNum">    5072 </span>            :   };
<span class="lineNum">    5073 </span>            : 
<span class="lineNum">    5074 </span>            :   struct wait_for_any_fctr {
<span class="lineNum">    5075 </span>            :     template &lt;class ...T&gt;
<span class="lineNum">    5076 </span>            :     void operator()(T&amp;&amp;... v) {
<span class="lineNum">    5077 </span>            :       boost::wait_for_any(boost::forward&lt;T&gt;(v)...);
<span class="lineNum">    5078 </span>            :     }
<span class="lineNum">    5079 </span>            :   };
<span class="lineNum">    5080 </span>            : 
<span class="lineNum">    5081 </span>            : 
<span class="lineNum">    5082 </span>            :   template &lt;class Tuple, std::size_t i=csbl::tuple_size&lt;Tuple&gt;::value&gt;
<span class="lineNum">    5083 </span>            :   struct accumulate_run_if_is_deferred {
<span class="lineNum">    5084 </span>            :     bool operator ()(Tuple&amp; t)
<span class="lineNum">    5085 </span>            :     {
<span class="lineNum">    5086 </span>            :       return (! csbl::get&lt;i-1&gt;(t).run_if_is_deferred()) || accumulate_run_if_is_deferred&lt;Tuple,i-1&gt;()(t);
<span class="lineNum">    5087 </span>            :     }
<span class="lineNum">    5088 </span>            :   };
<span class="lineNum">    5089 </span>            :   template &lt;class Tuple&gt;
<span class="lineNum">    5090 </span>            :   struct accumulate_run_if_is_deferred&lt;Tuple, 0&gt; {
<span class="lineNum">    5091 </span>            :     bool operator ()(Tuple&amp; )
<span class="lineNum">    5092 </span>            :     {
<span class="lineNum">    5093 </span>            :       return false;
<span class="lineNum">    5094 </span>            :     }
<span class="lineNum">    5095 </span>            :   };
<span class="lineNum">    5096 </span>            : 
<span class="lineNum">    5097 </span>            : 
<span class="lineNum">    5098 </span>            :   template&lt; typename Tuple, typename T0, typename ...T&gt;
<span class="lineNum">    5099 </span>            :   struct future_when_all_tuple_shared_state: future_async_shared_state_base&lt;Tuple&gt;
<span class="lineNum">    5100 </span>            :   {
<span class="lineNum">    5101 </span>            :     Tuple tup_;
<span class="lineNum">    5102 </span>            :     typedef typename make_tuple_indices&lt;1+sizeof...(T)&gt;::type Index;
<span class="lineNum">    5103 </span>            : 
<span class="lineNum">    5104 </span>            :     static void run(shared_ptr&lt;boost::detail::shared_state_base&gt; that_) {
<span class="lineNum">    5105 </span>            :       future_when_all_tuple_shared_state* that = dynamic_cast&lt;future_when_all_tuple_shared_state*&gt;(that_.get());
<span class="lineNum">    5106 </span>            :       try {
<span class="lineNum">    5107 </span>            :         // TODO make use of apply(that-&gt;tup_, boost::detail::wait_for_all_fctor());
<span class="lineNum">    5108 </span>            :         that-&gt;wait_for_all(Index());
<span class="lineNum">    5109 </span>            : 
<span class="lineNum">    5110 </span>            :         that-&gt;mark_finished_with_result(boost::move(that-&gt;tup_));
<span class="lineNum">    5111 </span>            :       } catch(...) {
<span class="lineNum">    5112 </span>            :         that-&gt;mark_exceptional_finish();
<span class="lineNum">    5113 </span>            :       }
<span class="lineNum">    5114 </span>            :     }
<span class="lineNum">    5115 </span>            : 
<span class="lineNum">    5116 </span>            :     template &lt;size_t ...Indices&gt;
<span class="lineNum">    5117 </span>            :     void wait_for_all(tuple_indices&lt;Indices...&gt;) {
<span class="lineNum">    5118 </span>            : #if defined BOOST_THREAD_PROVIDES_INVOKE
<span class="lineNum">    5119 </span>            :       return invoke&lt;void&gt;(wait_for_all_fctr(), csbl::get&lt;Indices&gt;(tup_)...);
<span class="lineNum">    5120 </span>            : #else
<span class="lineNum">    5121 </span>            :       return wait_for_all_fctr()(csbl::get&lt;Indices&gt;(tup_)...);
<span class="lineNum">    5122 </span>            : #endif
<span class="lineNum">    5123 </span>            :     }
<span class="lineNum">    5124 </span>            : 
<span class="lineNum">    5125 </span>            :     bool run_deferred() {
<span class="lineNum">    5126 </span>            : 
<span class="lineNum">    5127 </span>            :       return accumulate_run_if_is_deferred&lt;Tuple&gt;()(tup_);
<span class="lineNum">    5128 </span>            :     }
<span class="lineNum">    5129 </span>            :     void init() {
<span class="lineNum">    5130 </span>            :       if (! run_deferred())
<span class="lineNum">    5131 </span>            :       {
<span class="lineNum">    5132 </span>            :         future_when_all_tuple_shared_state::run(this-&gt;shared_from_this());
<span class="lineNum">    5133 </span>            :         return;
<span class="lineNum">    5134 </span>            :       }
<span class="lineNum">    5135 </span>            : 
<span class="lineNum">    5136 </span>            :       this-&gt;thr_ = thread(&amp;future_when_all_tuple_shared_state::run, this-&gt;shared_from_this());
<span class="lineNum">    5137 </span>            :     }
<span class="lineNum">    5138 </span>            :   public:
<span class="lineNum">    5139 </span>            :     template&lt; typename F, typename ...Fs&gt;
<span class="lineNum">    5140 </span>            :     future_when_all_tuple_shared_state(values_tag, BOOST_THREAD_FWD_REF(F) f, BOOST_THREAD_FWD_REF(Fs) ... futures) :
<span class="lineNum">    5141 </span>            :       tup_(boost::csbl::make_tuple(boost::forward&lt;F&gt;(f), boost::forward&lt;Fs&gt;(futures)...))
<span class="lineNum">    5142 </span>            :     {
<span class="lineNum">    5143 </span>            :     }
<span class="lineNum">    5144 </span>            : 
<span class="lineNum">    5145 </span>            :     ~future_when_all_tuple_shared_state() {}
<span class="lineNum">    5146 </span>            : 
<span class="lineNum">    5147 </span>            :   };
<span class="lineNum">    5148 </span>            : 
<span class="lineNum">    5149 </span>            : 
<span class="lineNum">    5150 </span>            :   template &lt;class Tuple, std::size_t i=csbl::tuple_size&lt;Tuple&gt;::value&gt;
<span class="lineNum">    5151 </span>            :   struct apply_any_run_if_is_deferred_or_ready {
<span class="lineNum">    5152 </span>            :     bool operator ()(Tuple&amp; t)
<span class="lineNum">    5153 </span>            :     {
<span class="lineNum">    5154 </span>            :       if (csbl::get&lt;i-1&gt;(t).run_if_is_deferred_or_ready()) return true;
<span class="lineNum">    5155 </span>            :       return apply_any_run_if_is_deferred_or_ready&lt;Tuple,i-1&gt;()(t);
<span class="lineNum">    5156 </span>            :     }
<span class="lineNum">    5157 </span>            :   };
<span class="lineNum">    5158 </span>            :   template &lt;class Tuple&gt;
<span class="lineNum">    5159 </span>            :   struct apply_any_run_if_is_deferred_or_ready&lt;Tuple, 0&gt; {
<span class="lineNum">    5160 </span>            :     bool operator ()(Tuple&amp; )
<span class="lineNum">    5161 </span>            :     {
<span class="lineNum">    5162 </span>            :       return false;
<span class="lineNum">    5163 </span>            :     }
<span class="lineNum">    5164 </span>            :   };
<span class="lineNum">    5165 </span>            : 
<span class="lineNum">    5166 </span>            :   template&lt; typename Tuple, typename T0, typename ...T &gt;
<span class="lineNum">    5167 </span>            :   struct future_when_any_tuple_shared_state: future_async_shared_state_base&lt;Tuple&gt;
<span class="lineNum">    5168 </span>            :   {
<span class="lineNum">    5169 </span>            :     Tuple tup_;
<span class="lineNum">    5170 </span>            :     typedef typename make_tuple_indices&lt;1+sizeof...(T)&gt;::type Index;
<span class="lineNum">    5171 </span>            : 
<span class="lineNum">    5172 </span>            :     static void run(shared_ptr&lt;boost::detail::shared_state_base&gt; that_)
<span class="lineNum">    5173 </span>            :     {
<span class="lineNum">    5174 </span>            :       future_when_any_tuple_shared_state* that = dynamic_cast&lt;future_when_any_tuple_shared_state*&gt;(that_.get());
<span class="lineNum">    5175 </span>            :       try {
<span class="lineNum">    5176 </span>            :         // TODO make use of apply(that-&gt;tup_, wait_for_any_fctr);
<span class="lineNum">    5177 </span>            :         that-&gt;wait_for_any(Index());
<span class="lineNum">    5178 </span>            : 
<span class="lineNum">    5179 </span>            :         that-&gt;mark_finished_with_result(boost::move(that-&gt;tup_));
<span class="lineNum">    5180 </span>            :       } catch(...) {
<span class="lineNum">    5181 </span>            :         that-&gt;mark_exceptional_finish();
<span class="lineNum">    5182 </span>            :       }
<span class="lineNum">    5183 </span>            :     }
<span class="lineNum">    5184 </span>            :     template &lt;size_t ...Indices&gt;
<span class="lineNum">    5185 </span>            :     void wait_for_any(tuple_indices&lt;Indices...&gt;) {
<span class="lineNum">    5186 </span>            : #if defined BOOST_THREAD_PROVIDES_INVOKE
<span class="lineNum">    5187 </span>            :       return invoke&lt;void&gt;(wait_for_any_fctr(), csbl::get&lt;Indices&gt;(tup_)...);
<span class="lineNum">    5188 </span>            : #else
<span class="lineNum">    5189 </span>            :       return wait_for_any_fctr()(csbl::get&lt;Indices&gt;(tup_)...);
<span class="lineNum">    5190 </span>            : #endif
<span class="lineNum">    5191 </span>            :     }
<span class="lineNum">    5192 </span>            :     bool run_deferred() {
<span class="lineNum">    5193 </span>            :       return apply_any_run_if_is_deferred_or_ready&lt;Tuple&gt;()(tup_);
<span class="lineNum">    5194 </span>            :     }
<span class="lineNum">    5195 </span>            :     void init() {
<span class="lineNum">    5196 </span>            :       if (run_deferred())
<span class="lineNum">    5197 </span>            :       {
<span class="lineNum">    5198 </span>            :         future_when_any_tuple_shared_state::run(this-&gt;shared_from_this());
<span class="lineNum">    5199 </span>            :         return;
<span class="lineNum">    5200 </span>            :       }
<span class="lineNum">    5201 </span>            : 
<span class="lineNum">    5202 </span>            :       this-&gt;thr_ = thread(&amp;future_when_any_tuple_shared_state::run, this-&gt;shared_from_this());
<span class="lineNum">    5203 </span>            :     }
<span class="lineNum">    5204 </span>            : 
<span class="lineNum">    5205 </span>            :   public:
<span class="lineNum">    5206 </span>            :     template&lt; typename F, typename ...Fs&gt;
<span class="lineNum">    5207 </span>            :     future_when_any_tuple_shared_state(values_tag,
<span class="lineNum">    5208 </span>            :         BOOST_THREAD_FWD_REF(F) f, BOOST_THREAD_FWD_REF(Fs) ... futures
<span class="lineNum">    5209 </span>            :     ) :
<span class="lineNum">    5210 </span>            :       tup_(boost::csbl::make_tuple(boost::forward&lt;F&gt;(f), boost::forward&lt;Fs&gt;(futures)...))
<span class="lineNum">    5211 </span>            :     {
<span class="lineNum">    5212 </span>            :     }
<span class="lineNum">    5213 </span>            : 
<span class="lineNum">    5214 </span>            :     ~future_when_any_tuple_shared_state() {}
<span class="lineNum">    5215 </span>            :   };
<span class="lineNum">    5216 </span>            : #endif
<span class="lineNum">    5217 </span>            : 
<span class="lineNum">    5218 </span>            : }
<span class="lineNum">    5219 </span>            : 
<span class="lineNum">    5220 </span>            :   template&lt; typename InputIterator&gt;
<span class="lineNum">    5221 </span>            :   typename boost::disable_if&lt;is_future_type&lt;InputIterator&gt;,
<span class="lineNum">    5222 </span>            :     BOOST_THREAD_FUTURE&lt;csbl::vector&lt;typename InputIterator::value_type&gt;  &gt;
<span class="lineNum">    5223 </span>            :   &gt;::type
<span class="lineNum">    5224 </span>            :   when_all(InputIterator first, InputIterator last) {
<span class="lineNum">    5225 </span>            :     typedef  typename InputIterator::value_type value_type;
<span class="lineNum">    5226 </span>            :     typedef  csbl::vector&lt;value_type&gt; container_type;
<span class="lineNum">    5227 </span>            :     typedef  detail::future_when_all_vector_shared_state&lt;value_type&gt; factory_type;
<span class="lineNum">    5228 </span>            : 
<span class="lineNum">    5229 </span>            :     if (first==last) return make_ready_future(container_type());
<span class="lineNum">    5230 </span>            :     shared_ptr&lt;factory_type &gt;
<span class="lineNum">    5231 </span>            :         h(new factory_type(detail::input_iterator_tag_value, first,last));
<span class="lineNum">    5232 </span>            :     h-&gt;init();
<span class="lineNum">    5233 </span>            :     return BOOST_THREAD_FUTURE&lt;container_type&gt;(h);
<span class="lineNum">    5234 </span>            :   }
<span class="lineNum">    5235 </span>            : 
<span class="lineNum">    5236 </span>            :   inline BOOST_THREAD_FUTURE&lt;csbl::tuple&lt;&gt; &gt; when_all() {
<span class="lineNum">    5237 </span>            :     return make_ready_future(csbl::tuple&lt;&gt;());
<span class="lineNum">    5238 </span>            :   }
<span class="lineNum">    5239 </span>            : 
<span class="lineNum">    5240 </span>            : #if ! defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
<span class="lineNum">    5241 </span>            :   template&lt; typename T0, typename ...T&gt;
<span class="lineNum">    5242 </span>            :   BOOST_THREAD_FUTURE&lt;csbl::tuple&lt;typename decay&lt;T0&gt;::type, typename decay&lt;T&gt;::type...&gt; &gt;
<span class="lineNum">    5243 </span>            :   when_all(BOOST_THREAD_FWD_REF(T0) f, BOOST_THREAD_FWD_REF(T) ... futures) {
<span class="lineNum">    5244 </span>            :     typedef csbl::tuple&lt;typename decay&lt;T0&gt;::type, typename decay&lt;T&gt;::type...&gt; container_type;
<span class="lineNum">    5245 </span>            :     typedef detail::future_when_all_tuple_shared_state&lt;container_type, typename decay&lt;T0&gt;::type, typename decay&lt;T&gt;::type...&gt; factory_type;
<span class="lineNum">    5246 </span>            : 
<span class="lineNum">    5247 </span>            :     shared_ptr&lt;factory_type&gt;
<span class="lineNum">    5248 </span>            :         h(new factory_type(detail::values_tag_value, boost::forward&lt;T0&gt;(f), boost::forward&lt;T&gt;(futures)...));
<span class="lineNum">    5249 </span>            :     h-&gt;init();
<span class="lineNum">    5250 </span>            :     return BOOST_THREAD_FUTURE&lt;container_type&gt;(h);
<span class="lineNum">    5251 </span>            :   }
<span class="lineNum">    5252 </span>            : #endif
<span class="lineNum">    5253 </span>            : 
<span class="lineNum">    5254 </span>            :   template&lt; typename InputIterator&gt;
<span class="lineNum">    5255 </span>            :   typename boost::disable_if&lt;is_future_type&lt;InputIterator&gt;,
<span class="lineNum">    5256 </span>            :     BOOST_THREAD_FUTURE&lt;csbl::vector&lt;typename InputIterator::value_type&gt;  &gt;
<span class="lineNum">    5257 </span>            :   &gt;::type
<span class="lineNum">    5258 </span>            :   when_any(InputIterator first, InputIterator last) {
<span class="lineNum">    5259 </span>            :     typedef  typename InputIterator::value_type value_type;
<span class="lineNum">    5260 </span>            :     typedef  csbl::vector&lt;value_type&gt; container_type;
<span class="lineNum">    5261 </span>            :     typedef  detail::future_when_any_vector_shared_state&lt;value_type&gt; factory_type;
<span class="lineNum">    5262 </span>            : 
<span class="lineNum">    5263 </span>            :     if (first==last) return make_ready_future(container_type());
<span class="lineNum">    5264 </span>            :     shared_ptr&lt;factory_type &gt;
<span class="lineNum">    5265 </span>            :         h(new factory_type(detail::input_iterator_tag_value, first,last));
<span class="lineNum">    5266 </span>            :     h-&gt;init();
<span class="lineNum">    5267 </span>            :     return BOOST_THREAD_FUTURE&lt;container_type&gt;(h);
<span class="lineNum">    5268 </span>            :   }
<span class="lineNum">    5269 </span>            : 
<span class="lineNum">    5270 </span>            :   inline BOOST_THREAD_FUTURE&lt;csbl::tuple&lt;&gt; &gt; when_any() {
<span class="lineNum">    5271 </span>            :     return make_ready_future(csbl::tuple&lt;&gt;());
<span class="lineNum">    5272 </span>            :   }
<span class="lineNum">    5273 </span>            : 
<span class="lineNum">    5274 </span>            : #if ! defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
<span class="lineNum">    5275 </span>            :   template&lt; typename T0, typename ...T&gt;
<span class="lineNum">    5276 </span>            :   BOOST_THREAD_FUTURE&lt;csbl::tuple&lt;typename decay&lt;T0&gt;::type, typename decay&lt;T&gt;::type...&gt; &gt;
<span class="lineNum">    5277 </span>            :   when_any(BOOST_THREAD_FWD_REF(T0) f, BOOST_THREAD_FWD_REF(T) ... futures) {
<span class="lineNum">    5278 </span>            :     typedef csbl::tuple&lt;typename decay&lt;T0&gt;::type, typename decay&lt;T&gt;::type...&gt; container_type;
<span class="lineNum">    5279 </span>            :     typedef detail::future_when_any_tuple_shared_state&lt;container_type, typename decay&lt;T0&gt;::type, typename decay&lt;T&gt;::type...&gt; factory_type;
<span class="lineNum">    5280 </span>            : 
<span class="lineNum">    5281 </span>            :     shared_ptr&lt;factory_type&gt;
<span class="lineNum">    5282 </span>            :         h(new factory_type(detail::values_tag_value, boost::forward&lt;T0&gt;(f), boost::forward&lt;T&gt;(futures)...));
<span class="lineNum">    5283 </span>            :     h-&gt;init();
<span class="lineNum">    5284 </span>            :     return BOOST_THREAD_FUTURE&lt;container_type&gt;(h);
<span class="lineNum">    5285 </span>            :   }
<span class="lineNum">    5286 </span>            : #endif
<span class="lineNum">    5287 </span>            : #endif // BOOST_THREAD_PROVIDES_FUTURE_WHEN_ALL_WHEN_ANY
<span class="lineNum">    5288 </span>            : }
<span class="lineNum">    5289 </span>            : 
<span class="lineNum">    5290 </span>            : #endif // BOOST_NO_EXCEPTION
<span class="lineNum">    5291 </span>            : #endif // header
</pre>
      </td>
    </tr>
  </table>
  <br>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="ruler"><img src="../../../../glass.png" width=3 height=3 alt=""></td></tr>
    <tr><td class="versionInfo">Generated by: <a href="http://ltp.sourceforge.net/coverage/lcov.php" target="_parent">LCOV version 1.12</a></td></tr>
  </table>
  <br>

</body>
</html>
